http: restore header folding behavior

Folded header lines will now get passed through like before. The headers
API is adapted and will provide the content unfolded.

Added test 1274 and extended test 1940 to verify.

Reported-by: Petr Pisar
Fixes #8844
Closes #8899
This commit is contained in:
Daniel Stenberg 2022-05-24 23:33:35 +02:00
parent 16a58e9f93
commit c9b60f0053
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 139 additions and 9 deletions

View file

@ -3799,11 +3799,16 @@ static CURLcode verify_header(struct Curl_easy *data)
if(k->headerline < 2)
/* the first "header" is the status-line and it has no colon */
return CURLE_OK;
ptr = memchr(header, ':', hlen);
if(!ptr) {
/* this is bad, bail out */
failf(data, "Header without colon");
return CURLE_WEIRD_SERVER_REPLY;
if(((header[0] == ' ') || (header[0] == '\t')) && k->headerline > 2)
/* line folding, can't happen on line 2 */
;
else {
ptr = memchr(header, ':', hlen);
if(!ptr) {
/* this is bad, bail out */
failf(data, "Header without colon");
return CURLE_WEIRD_SERVER_REPLY;
}
}
return CURLE_OK;
}