]> granicus.if.org Git - curl/commitdiff
http: add custom empty headers to repeated requests
authorMichael Kaufmann <mail@michael-kaufmann.ch>
Sun, 24 Sep 2017 17:31:43 +0000 (19:31 +0200)
committerMichael Kaufmann <mail@michael-kaufmann.ch>
Thu, 28 Sep 2017 19:25:22 +0000 (21:25 +0200)
Closes #1920

lib/http.c
tests/data/test4

index ea3e8af3577865d5ade0d137f62454695b7e37d0..38227eb6cfa31f7a37a2b48ba2248a971790c1a2 100644 (file)
@@ -1626,12 +1626,12 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
           else if(conn->bits.authneg &&
                   /* while doing auth neg, don't allow the custom length since
                      we will force length zero then */
-                  checkprefix("Content-Length", headers->data))
+                  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))
+                  checkprefix("Connection:", headers->data))
             ;
           else if((conn->httpversion == 20) &&
                   checkprefix("Transfer-Encoding:", headers->data))
@@ -1664,6 +1664,10 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
               *ptr = ':';
               result = Curl_add_bufferf(req_buffer, "%s\r\n",
                                         headers->data);
+
+              /* restore the previous value */
+              *ptr = ';';
+
               if(result)
                 return result;
             }
index df69d3274a2af21152891c87f5c32828a83fbadf..542347db5f1d279caf218434e6fe8e0ad47d298f 100644 (file)
@@ -30,7 +30,7 @@ http
 Replaced internal and added custom HTTP headers
  </name>
  <command>
- -H "extra-header: here" -H "Accept: replaced" -H "X-Custom-Header;" -H "X-Test: foo; " -H "X-Test:" -H "X-Test2: foo;" -H "X-Test3:  " -H "X-Test4;  " -H "X-Test5;ignored" http://%HOSTIP:%HTTPPORT/4
+ -H "extra-header: here" -H "Accept: replaced" -H "X-Custom-Header;" -H "X-Test: foo; " -H "X-Test:" -H "X-Test2: foo;" -H "X-Test3:  " -H "X-Test4;  " -H "X-Test5;ignored" http://%HOSTIP:%HTTPPORT/4 http://%HOSTIP:%HTTPPORT/4
 </command>
 </client>
 
@@ -49,6 +49,14 @@ X-Custom-Header:
 X-Test: foo; \r
 X-Test2: foo;\r
 \r
+GET /4 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+extra-header: here\r
+Accept: replaced\r
+X-Custom-Header:\r
+X-Test: foo; \r
+X-Test2: foo;\r
+\r
 </protocol>
 </verify>
 </testcase>