Commit 9d191a6a authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

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:.
parent be973b6f
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
 test1203 test1117 test1118 test1119 test1120 test1300 test1301 test1302 \
 test1303 test320 test321 test322 test323 test324 test1121 test581 test580 \
 test1304 test1305 test1306 test1307 test582 test583 test808 test809       \
 test810 test811 test812 test813 test584 test1122 test1123 test1124
 test810 test811 test812 test813 test584 test1122 test1123 test1124 test1125

filecheck:
	@mkdir test-place; \
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ http://%HOSTIP:%HTTPPORT/1122 -H "TE: gzip"
GET /1122 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
Connection: TE
TE: gzip

</protocol>
+1 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ http://%HOSTIP:%HTTPPORT/1123 -H "TE: deflate, gzip"
GET /1123 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
Connection: TE
TE: deflate, gzip

</protocol>
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ http://%HOSTIP:%HTTPPORT/1124 -H "TE: gzip"
GET /1124 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
Connection: TE
TE: gzip

</protocol>
Loading