aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-04-11 16:30:14 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-04-18 19:46:21 +0200
commit9d191a6a40c2e90153d4b60cbc78fa34837c07ee (patch)
tree08eb3cf20b9d37bbbb69ee95fad632bd5ea48a3d /lib
parentbe973b6f91a2116a2c68c9d0d0e8a5f3fc6e23c6 (diff)
TE: do the Connection: header
When TE: is inserted in the request, we must add a "Connection: TE" as well to be HTTP 1.1 compliant. If a custom Connection: header is passed in, we must use that and only append TE to it. Test case 1125 verifies TE: + custom Connection:.
Diffstat (limited to 'lib')
-rw-r--r--lib/http.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/http.c b/lib/http.c
index c442eebab..8d3a085d0 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1533,6 +1533,11 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
we will force length zero then */
checkprefix("Content-Length", headers->data))
;
+ else if(conn->allocptr.te &&
+ /* when asking for Transfer-Encoding, don't pass on a custom
+ Connection: */
+ checkprefix("Connection", headers->data))
+ ;
else {
CURLcode result = Curl_add_bufferf(req_buffer, "%s\r\n",
headers->data);
@@ -1728,14 +1733,21 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
return CURLE_OUT_OF_MEMORY;
}
-#if 0
- if(!Curl_checkheaders(data, "TE:")) {
+ if(Curl_checkheaders(data, "TE:")) {
+ /* When we insert a TE: header in the request, we must also insert TE in a
+ Connection: header, so we need to merge the custom provided Connection:
+ header and prevent the original to get sent */
+ char *cptr = Curl_checkheaders(data, "Connection:");
+
Curl_safefree(conn->allocptr.te);
- conn->allocptr.te = aprintf("TE: %s\r\n", "gzip");
+
+ /* Create the (updated) Connection: header */
+ conn->allocptr.te = cptr? aprintf("%s, TE\r\n", cptr):
+ strdup("Connection: TE\r\n");
+
if(!conn->allocptr.te)
return CURLE_OUT_OF_MEMORY;
}
-#endif
ptr = Curl_checkheaders(data, "Transfer-Encoding:");
if(ptr) {