mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:23:39 +03:00
misc: reduce strlen() calls with Curl_dyn_add()
Use STRCONST() to switch from Curl_dyn_add() to Curl_dyn_addn() for string literals. Closes #8398
This commit is contained in:
parent
2a1951519e
commit
b807219292
7 changed files with 37 additions and 34 deletions
34
lib/http.c
34
lib/http.c
|
|
@ -1540,7 +1540,7 @@ static CURLcode add_haproxy_protocol_header(struct Curl_easy *data)
|
|||
#ifdef USE_UNIX_SOCKETS
|
||||
if(data->conn->unix_domain_socket)
|
||||
/* the buffer is large enough to hold this! */
|
||||
result = Curl_dyn_add(&req, "PROXY UNKNOWN\r\n");
|
||||
result = Curl_dyn_addn(&req, STRCONST("PROXY UNKNOWN\r\n"));
|
||||
else {
|
||||
#endif
|
||||
/* Emit the correct prefix for IPv6 */
|
||||
|
|
@ -1713,7 +1713,7 @@ static CURLcode expect100(struct Curl_easy *data,
|
|||
Curl_compareheader(ptr, STRCONST("Expect:"), STRCONST("100-continue"));
|
||||
}
|
||||
else {
|
||||
result = Curl_dyn_add(req, "Expect: 100-continue\r\n");
|
||||
result = Curl_dyn_addn(req, STRCONST("Expect: 100-continue\r\n"));
|
||||
if(!result)
|
||||
data->state.expect100header = TRUE;
|
||||
}
|
||||
|
|
@ -2404,7 +2404,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
}
|
||||
|
||||
/* end of headers */
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
@ -2429,7 +2429,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
/* This is form posting using mime data. */
|
||||
if(conn->bits.authneg) {
|
||||
/* nothing to post! */
|
||||
result = Curl_dyn_add(r, "Content-Length: 0\r\n\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("Content-Length: 0\r\n\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
@ -2490,7 +2490,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
data->state.expect100header = FALSE;
|
||||
|
||||
/* make the request end in a true CRLF */
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
@ -2539,8 +2539,8 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
}
|
||||
|
||||
if(!Curl_checkheaders(data, "Content-Type")) {
|
||||
result = Curl_dyn_add(r, "Content-Type: application/"
|
||||
"x-www-form-urlencoded\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("Content-Type: application/"
|
||||
"x-www-form-urlencoded\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2579,7 +2579,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
get the data duplicated with malloc() and family. */
|
||||
|
||||
/* end of headers! */
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
@ -2601,12 +2601,12 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
result = Curl_dyn_addn(r, data->set.postfields,
|
||||
(size_t)http->postsize);
|
||||
if(!result)
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
included_body += 2;
|
||||
}
|
||||
}
|
||||
if(!result) {
|
||||
result = Curl_dyn_add(r, "\x30\x0d\x0a\x0d\x0a");
|
||||
result = Curl_dyn_addn(r, STRCONST("\x30\x0d\x0a\x0d\x0a"));
|
||||
/* 0 CR LF CR LF */
|
||||
included_body += 5;
|
||||
}
|
||||
|
|
@ -2629,7 +2629,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
Curl_pgrsSetUploadSize(data, http->postsize);
|
||||
|
||||
/* end of headers! */
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2638,14 +2638,14 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
#endif
|
||||
{
|
||||
/* end of headers! */
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
if(data->req.upload_chunky && conn->bits.authneg) {
|
||||
/* Chunky upload is selected and we're negotiating auth still, send
|
||||
end-of-data only */
|
||||
result = Curl_dyn_add(r, (char *)"\x30\x0d\x0a\x0d\x0a");
|
||||
result = Curl_dyn_addn(r, (char *)STRCONST("\x30\x0d\x0a\x0d\x0a"));
|
||||
/* 0 CR LF CR LF */
|
||||
if(result)
|
||||
return result;
|
||||
|
|
@ -2673,7 +2673,7 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
|
|||
break;
|
||||
|
||||
default:
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
if(result)
|
||||
return result;
|
||||
|
||||
|
|
@ -2723,7 +2723,7 @@ CURLcode Curl_http_cookies(struct Curl_easy *data,
|
|||
while(co) {
|
||||
if(co->value) {
|
||||
if(0 == count) {
|
||||
result = Curl_dyn_add(r, "Cookie: ");
|
||||
result = Curl_dyn_addn(r, STRCONST("Cookie: "));
|
||||
if(result)
|
||||
break;
|
||||
}
|
||||
|
|
@ -2739,14 +2739,14 @@ CURLcode Curl_http_cookies(struct Curl_easy *data,
|
|||
}
|
||||
if(addcookies && !result) {
|
||||
if(!count)
|
||||
result = Curl_dyn_add(r, "Cookie: ");
|
||||
result = Curl_dyn_addn(r, STRCONST("Cookie: "));
|
||||
if(!result) {
|
||||
result = Curl_dyn_addf(r, "%s%s", count?"; ":"", addcookies);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count && !result)
|
||||
result = Curl_dyn_add(r, "\r\n");
|
||||
result = Curl_dyn_addn(r, STRCONST("\r\n"));
|
||||
|
||||
if(result)
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue