mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:43:34 +03:00
lib: new easy option string storage
Change the storage of easy handle option strings from an array sized for all possible options to a hash set to reduce memory footprint. Give the hash set initially room for 4 strings, with first allocation happening when it goes beyond that. Measurements without test suite and a forced fail on growing the set gives: Size Result 2 1261 tests out of 1951 reported OK: 64% 4 1792 tests out of 1951 reported OK: 91% 8 1944 tests out of 1951 reported OK: 99% 16 1949 tests out of 1951 reported OK: 99% 32 single fail of 3211, unit test for u8_strset Add u8_strset that keeps the tuples (uint8_t id, char *str) and allows set/unset by `id`. Add that as data->set.strings. Define MACROS * CURL_EASY_STR(data, id) for access * CURL_EASY_STR_SET(data, id, s) for setting, making a copy * CURL_EASY_STR_SETN(data, id, s) for setting, no copy * CURL_EASY_STR_CLEAR(data, id) for unsetting * CURL_EASY_STR_CLEAR0(data, id) for unsetting and zero-ing value Add `data->set.str_copypostfields` to handle former `STRING_COPYPOSTFIELDS` string that was not always a string and could carry NUL bytes. Add unit tests to test3211. Closes #22628
This commit is contained in:
parent
961c95fea6
commit
c8df3defd9
45 changed files with 1028 additions and 488 deletions
|
|
@ -201,6 +201,7 @@ static CURLcode http_proxy_create_CONNECT(struct httpreq **preq,
|
|||
proxy_http_ver ver)
|
||||
{
|
||||
char *authority = NULL;
|
||||
const char *ua;
|
||||
int httpversion = proxy_http_ver_major(ver);
|
||||
CURLcode result;
|
||||
struct httpreq *req = NULL;
|
||||
|
|
@ -242,10 +243,10 @@ static CURLcode http_proxy_create_CONNECT(struct httpreq **preq,
|
|||
goto out;
|
||||
}
|
||||
|
||||
ua = CURL_EASY_STR(data, STRING_USERAGENT);
|
||||
if(!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent")) &&
|
||||
data->set.str[STRING_USERAGENT] && *data->set.str[STRING_USERAGENT]) {
|
||||
result = Curl_dynhds_cadd(&req->headers, "User-Agent",
|
||||
data->set.str[STRING_USERAGENT]);
|
||||
ua && *ua) {
|
||||
result = Curl_dynhds_cadd(&req->headers, "User-Agent", ua);
|
||||
if(result)
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -276,7 +277,7 @@ static CURLcode http_proxy_create_CONNECTUDP(struct httpreq **preq,
|
|||
struct Curl_peer *dest,
|
||||
proxy_http_ver ver)
|
||||
{
|
||||
const char *proxy_scheme = "http";
|
||||
const char *proxy_scheme = "http", *ua;
|
||||
const char *proxy_host = cf->conn->http_proxy.peer->hostname;
|
||||
int httpversion = proxy_http_ver_major(ver);
|
||||
char *authority = NULL;
|
||||
|
|
@ -381,11 +382,11 @@ static CURLcode http_proxy_create_CONNECTUDP(struct httpreq **preq,
|
|||
goto out;
|
||||
}
|
||||
|
||||
ua = CURL_EASY_STR(data, STRING_USERAGENT);
|
||||
if(ver == PROXY_HTTP_V1 &&
|
||||
!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent")) &&
|
||||
data->set.str[STRING_USERAGENT] && *data->set.str[STRING_USERAGENT]) {
|
||||
result = Curl_dynhds_cadd(&req->headers, "User-Agent",
|
||||
data->set.str[STRING_USERAGENT]);
|
||||
ua && *ua) {
|
||||
result = Curl_dynhds_cadd(&req->headers, "User-Agent", ua);
|
||||
if(result)
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue