Curl_http(), decomplexify

Split out adding of individual request headers into a switch. Check
the connection http version only on fresh connections, use separate
methods.

Add TE: header directly without allocation. Add bit for indicating
Connection: header has been added and custom headers should not do
that again.

Closes #18444
This commit is contained in:
Stefan Eissing 2025-09-01 15:52:30 +02:00 committed by Daniel Stenberg
parent e00cb001c6
commit 4d040c71d7
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
25 changed files with 345 additions and 319 deletions

View file

@ -1023,11 +1023,6 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req)
MUST include the "websocket" keyword. */
"Upgrade", "websocket"
},
{
/* The request MUST contain a |Connection| header field whose value
MUST include the "Upgrade" token. */
"Connection", "Upgrade",
},
{
/* The request MUST include a header field with the name
|Sec-WebSocket-Version|. The value of this header field MUST be
@ -1043,7 +1038,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req)
"Sec-WebSocket-Key", NULL,
}
};
heads[3].val = &keyval[0];
heads[2].val = &keyval[0];
/* 16 bytes random */
result = Curl_rand(data, (unsigned char *)rand, sizeof(rand));
@ -1065,6 +1060,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req)
heads[i].val);
}
}
data->state.http_hd_upgrade = TRUE;
k->upgr101 = UPGR101_WS;
return result;
}