1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

http: add custom empty headers to repeated requests

Closes #1920
This commit is contained in:
Michael Kaufmann 2017-09-24 19:31:43 +02:00
parent 284d06df9e
commit eac324f284
2 changed files with 15 additions and 3 deletions

View File

@ -1626,12 +1626,12 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
else if(conn->bits.authneg && else if(conn->bits.authneg &&
/* while doing auth neg, don't allow the custom length since /* while doing auth neg, don't allow the custom length since
we will force length zero then */ we will force length zero then */
checkprefix("Content-Length", headers->data)) checkprefix("Content-Length:", headers->data))
; ;
else if(conn->allocptr.te && else if(conn->allocptr.te &&
/* when asking for Transfer-Encoding, don't pass on a custom /* when asking for Transfer-Encoding, don't pass on a custom
Connection: */ Connection: */
checkprefix("Connection", headers->data)) checkprefix("Connection:", headers->data))
; ;
else if((conn->httpversion == 20) && else if((conn->httpversion == 20) &&
checkprefix("Transfer-Encoding:", headers->data)) checkprefix("Transfer-Encoding:", headers->data))
@ -1664,6 +1664,10 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
*ptr = ':'; *ptr = ':';
result = Curl_add_bufferf(req_buffer, "%s\r\n", result = Curl_add_bufferf(req_buffer, "%s\r\n",
headers->data); headers->data);
/* restore the previous value */
*ptr = ';';
if(result) if(result)
return result; return result;
} }

View File

@ -30,7 +30,7 @@ http
Replaced internal and added custom HTTP headers Replaced internal and added custom HTTP headers
</name> </name>
<command> <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> </command>
</client> </client>
@ -49,6 +49,14 @@ X-Custom-Header:
X-Test: foo; X-Test: foo;
X-Test2: foo; X-Test2: foo;
GET /4 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
extra-header: here
Accept: replaced
X-Custom-Header:
X-Test: foo;
X-Test2: foo;
</protocol> </protocol>
</verify> </verify>
</testcase> </testcase>