← Commit list

3388afd2b6

Daniel Stenberg
Daniel Stenberg
2025-12-19
SUCCESS Duration: 201s

Subject

http: more unfold fixing

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/http.c+19 -18
@@ -4344,6 +4344,23 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
size_t consumed;
size_t hlen;
char *hd;
+ size_t unfold_len = 0;
+
+ if(data->state.leading_unfold) {
+ /* immediately after an unfold, keep only a single whitespace */
+ while(blen && ISBLANK(buf[0])) {
+ buf++;
+ blen--;
+ unfold_len++;
+ }
+ if(blen) {
+ /* insert a single space */
+ result = curlx_dyn_addn(&data->state.headerb, " ", 1);
+ if(result)
+ return result;
+ data->state.leading_unfold = FALSE; /* done now */
+ }
+ }
end_ptr = memchr(buf, '\n', blen);
if(!end_ptr) {
@@ -4352,7 +4369,7 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
result = curlx_dyn_addn(&data->state.headerb, buf, blen);
if(result)
return result;
- *pconsumed += blen;
+ *pconsumed += blen + unfold_len;
if(!k->headerline) {
/* check if this looks like a protocol header */
@@ -4388,22 +4405,6 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
/* preserve the whole original header piece size */
size_t header_piece = consumed;
- if(data->state.leading_unfold) {
- /* immediately after an unfold, keep only a single whitespace */
- while(consumed && ISBLANK(buf[0])) {
- consumed--;
- buf++;
- blen--;
- }
- if(consumed) {
- /* insert a single space */
- result = curlx_dyn_addn(&data->state.headerb, " ", 1);
- if(result)
- return result;
- data->state.leading_unfold = FALSE; /* done now */
- }
- }
-
if(consumed) {
result = curlx_dyn_addn(&data->state.headerb, buf, consumed);
if(result)
@@ -4411,7 +4412,7 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
blen -= consumed;
buf += consumed;
}
- *pconsumed += header_piece;
+ *pconsumed += header_piece + unfold_len;
}
/****
tests/data/test798+3 -0
@@ -22,6 +22,9 @@ Set-Cookie: flavor=tasty;
boo
</data>
+<servercmd>
+writedelay: 20
+</servercmd>
</reply>
# Client-side