diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-06-19 21:49:25 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-06-19 21:49:25 +0000 |
commit | 4f249f9d0ab7701876cc5bd6be2338de8dae8e35 (patch) | |
tree | f1dab5655f88b29efae58b4041248ef633fb6c15 /content/fetch.c | |
parent | cc226c02930d6af81352237e258024b69cc873e5 (diff) | |
download | netsurf-4f249f9d0ab7701876cc5bd6be2338de8dae8e35.tar.gz netsurf-4f249f9d0ab7701876cc5bd6be2338de8dae8e35.tar.bz2 |
Merge cookies changes into head - unvalidated transactions and a UI
still need implementing.
svn path=/trunk/netsurf/; revision=2632
Diffstat (limited to 'content/fetch.c')
-rw-r--r-- | content/fetch.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/content/fetch.c b/content/fetch.c index a504e4b53..619df0dfb 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -70,6 +70,7 @@ struct fetch { char *host; /**< Host part of URL. */ char *location; /**< Response Location header, or 0. */ unsigned long content_length; /**< Response Content-Length, or 0. */ + char *cookie_string; /**< Cookie string for this fetch */ char *realm; /**< HTTP Auth Realm */ char *post_urlenc; /**< Url encoded POST string, or 0. */ struct curl_httppost *post_multipart; /**< Multipart post data, or 0. */ @@ -356,6 +357,7 @@ struct fetch * fetch_start(char *url, char *referer, fetch->host = host; fetch->location = 0; fetch->content_length = 0; + fetch->cookie_string = 0; fetch->realm = 0; fetch->post_urlenc = 0; fetch->post_multipart = 0; @@ -635,13 +637,9 @@ CURLcode fetch_set_options(struct fetch *f) SETOPT(CURLOPT_HTTPGET, 1L); } if (f->cookies) { - if (option_cookie_file) - SETOPT(CURLOPT_COOKIEFILE, option_cookie_file); - if (option_cookie_jar) - SETOPT(CURLOPT_COOKIEJAR, option_cookie_jar); - } else { - SETOPT(CURLOPT_COOKIEFILE, 0); - SETOPT(CURLOPT_COOKIEJAR, 0); + f->cookie_string = urldb_get_cookie(f->url, f->referer); + if (f->cookie_string) + SETOPT(CURLOPT_COOKIE, f->cookie_string); } #ifdef WITH_AUTH if ((auth = urldb_get_auth_details(f->url)) != NULL) { @@ -771,6 +769,7 @@ void fetch_free(struct fetch *f) free(f->host); free(f->referer); free(f->location); + free(f->cookie_string); free(f->realm); if (f->headers) curl_slist_free_all(f->headers); @@ -1175,6 +1174,10 @@ size_t fetch_curl_header(char *data, size_t size, size_t nmemb, f->cachedata.last_modified = curl_getdate(&data[i], NULL); } + } else if (11 < size && strncasecmp(data, "Set-Cookie:", 11) == 0) { + /* extract Set-Cookie header */ + SKIP_ST(11); + urldb_set_cookie(&data[i], f->url); } return size; |