mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
cookies: when reading from a file, only remove_expired once
This drops the cookie load time for 8k cookies from 178ms to 15ms. Closes #2441
This commit is contained in:
parent
28faaacee2
commit
4073cd83b2
@ -368,6 +368,7 @@ Curl_cookie_add(struct Curl_easy *data,
|
|||||||
|
|
||||||
struct CookieInfo *c,
|
struct CookieInfo *c,
|
||||||
bool httpheader, /* TRUE if HTTP header-style line */
|
bool httpheader, /* TRUE if HTTP header-style line */
|
||||||
|
bool noexpire, /* if TRUE, skip remove_expired() */
|
||||||
char *lineptr, /* first character of the line */
|
char *lineptr, /* first character of the line */
|
||||||
const char *domain, /* default domain */
|
const char *domain, /* default domain */
|
||||||
const char *path) /* full path used when this cookie is set,
|
const char *path) /* full path used when this cookie is set,
|
||||||
@ -819,6 +820,7 @@ Curl_cookie_add(struct Curl_easy *data,
|
|||||||
the same domain and path as this */
|
the same domain and path as this */
|
||||||
|
|
||||||
/* at first, remove expired cookies */
|
/* at first, remove expired cookies */
|
||||||
|
if(!noexpire)
|
||||||
remove_expired(c);
|
remove_expired(c);
|
||||||
|
|
||||||
#ifdef USE_LIBPSL
|
#ifdef USE_LIBPSL
|
||||||
@ -1026,9 +1028,10 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
|
|||||||
while(*lineptr && ISBLANK(*lineptr))
|
while(*lineptr && ISBLANK(*lineptr))
|
||||||
lineptr++;
|
lineptr++;
|
||||||
|
|
||||||
Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL);
|
Curl_cookie_add(data, c, headerline, TRUE, lineptr, NULL, NULL);
|
||||||
}
|
}
|
||||||
free(line); /* free the line buffer */
|
free(line); /* free the line buffer */
|
||||||
|
remove_expired(c); /* run this once, not on every cookie */
|
||||||
|
|
||||||
if(fromfile)
|
if(fromfile)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -80,7 +80,8 @@ struct Curl_easy;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct Cookie *Curl_cookie_add(struct Curl_easy *data,
|
struct Cookie *Curl_cookie_add(struct Curl_easy *data,
|
||||||
struct CookieInfo *, bool header, char *lineptr,
|
struct CookieInfo *, bool header, bool noexpiry,
|
||||||
|
char *lineptr,
|
||||||
const char *domain, const char *path);
|
const char *domain, const char *path);
|
||||||
|
|
||||||
struct Cookie *Curl_cookie_getlist(struct CookieInfo *, const char *,
|
struct Cookie *Curl_cookie_getlist(struct CookieInfo *, const char *,
|
||||||
|
@ -3734,7 +3734,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
|
|||||||
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE,
|
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE,
|
||||||
CURL_LOCK_ACCESS_SINGLE);
|
CURL_LOCK_ACCESS_SINGLE);
|
||||||
Curl_cookie_add(data,
|
Curl_cookie_add(data,
|
||||||
data->cookies, TRUE, k->p + 11,
|
data->cookies, TRUE, FALSE, k->p + 11,
|
||||||
/* If there is a custom-set Host: name, use it
|
/* If there is a custom-set Host: name, use it
|
||||||
here, or else use real peer host name. */
|
here, or else use real peer host name. */
|
||||||
conn->allocptr.cookiehost?
|
conn->allocptr.cookiehost?
|
||||||
|
@ -781,11 +781,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
|
|||||||
|
|
||||||
if(checkprefix("Set-Cookie:", argptr))
|
if(checkprefix("Set-Cookie:", argptr))
|
||||||
/* HTTP Header format line */
|
/* HTTP Header format line */
|
||||||
Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);
|
Curl_cookie_add(data, data->cookies, TRUE, FALSE, argptr + 11, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
else
|
else
|
||||||
/* Netscape format line */
|
/* Netscape format line */
|
||||||
Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
|
Curl_cookie_add(data, data->cookies, FALSE, FALSE, argptr, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
||||||
free(argptr);
|
free(argptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user