http: make Curl_compareheader() take string length arguments too

Also add STRCONST, a macro that returns a string literal and it's length
for functions that take "string,len"

Removes unnecesary calls to strlen().

Closes #8391
This commit is contained in:
HenrikHolst 2022-02-04 20:41:35 +01:00 committed by Daniel Stenberg
parent a42677f0d8
commit 4028892f14
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 39 additions and 17 deletions

View file

@ -589,7 +589,8 @@ static CURLcode CONNECT(struct Curl_easy *data,
strlen("Content-Length:"), NULL, 10, &s->cl);
}
}
else if(Curl_compareheader(linep, "Connection:", "close"))
else if(Curl_compareheader(linep,
STRCONST("Connection:"), STRCONST("close")))
s->close_connection = TRUE;
else if(checkprefix("Transfer-Encoding:", linep)) {
if(k->httpcode/100 == 2) {
@ -600,14 +601,17 @@ static CURLcode CONNECT(struct Curl_easy *data,
"CONNECT %03d response", k->httpcode);
}
else if(Curl_compareheader(linep,
"Transfer-Encoding:", "chunked")) {
STRCONST("Transfer-Encoding:"),
STRCONST("chunked"))) {
infof(data, "CONNECT responded chunked");
s->chunked_encoding = TRUE;
/* init our chunky engine */
Curl_httpchunk_init(data);
}
}
else if(Curl_compareheader(linep, "Proxy-Connection:", "close"))
else if(Curl_compareheader(linep,
STRCONST("Proxy-Connection:"),
STRCONST("close")))
s->close_connection = TRUE;
else if(2 == sscanf(linep, "HTTP/1.%d %d",
&subversion,