mirror of
https://github.com/curl/curl.git
synced 2026-08-24 19:23:38 +03:00
cookie: simplifications
- add Curl_secure_context(), to have it determined in a single place. - tweak the Curl_cookie_getlist() proto. Move some logic into the function - at is only called in a single place. Instead of forcing the caller to do it. - make 'is_ip' a const Closes #18419
This commit is contained in:
parent
f08ecdc586
commit
fe01ace248
3 changed files with 22 additions and 27 deletions
18
lib/http.c
18
lib/http.c
|
|
@ -2442,14 +2442,8 @@ static CURLcode http_cookies(struct Curl_easy *data,
|
|||
if(data->cookies && data->state.cookie_engine) {
|
||||
const char *host = data->state.aptr.cookiehost ?
|
||||
data->state.aptr.cookiehost : conn->host.name;
|
||||
const bool secure_context =
|
||||
conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) ||
|
||||
curl_strequal("localhost", host) ||
|
||||
!strcmp(host, "127.0.0.1") ||
|
||||
!strcmp(host, "::1");
|
||||
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
|
||||
rc = Curl_cookie_getlist(data, data->cookies, host, data->state.up.path,
|
||||
secure_context, &list);
|
||||
rc = Curl_cookie_getlist(data, conn, host, &list);
|
||||
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
||||
}
|
||||
if(!rc) {
|
||||
|
|
@ -3334,14 +3328,8 @@ static CURLcode http_header_s(struct Curl_easy *data,
|
|||
* real peer hostname. */
|
||||
const char *host = data->state.aptr.cookiehost ?
|
||||
data->state.aptr.cookiehost : conn->host.name;
|
||||
const bool secure_context =
|
||||
conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) ||
|
||||
curl_strequal("localhost", host) ||
|
||||
!strcmp(host, "127.0.0.1") ||
|
||||
!strcmp(host, "::1");
|
||||
|
||||
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE,
|
||||
CURL_LOCK_ACCESS_SINGLE);
|
||||
const bool secure_context = Curl_secure_context(conn, host);
|
||||
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
|
||||
Curl_cookie_add(data, data->cookies, TRUE, FALSE, v, host,
|
||||
data->state.up.path, secure_context);
|
||||
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue