summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorChris Williams <chris@diodesign.co.uk>2006-10-01 13:17:52 +0000
committerChris Williams <chris@diodesign.co.uk>2006-10-01 13:17:52 +0000
commitf4e4ec00b71818e7364e1efc3d95a303ff23e361 (patch)
tree9e8c1716d25573011565af06635436f1a9280381 /content
parent45f2c3cfa3e7584c553f4d8bdb7c642ad25bcef4 (diff)
downloadnetsurf-f4e4ec00b71818e7364e1efc3d95a303ff23e361.tar.gz
netsurf-f4e4ec00b71818e7364e1efc3d95a303ff23e361.tar.bz2
Ignore body data from 401 replies to prevent disruption of auth login handling
svn path=/trunk/netsurf/; revision=2972
Diffstat (limited to 'content')
-rw-r--r--content/fetch.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/content/fetch.c b/content/fetch.c
index c9c448736..42526f187 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. */
+ long http_code; /**< HTTP response code, or 0. */
char *cookie_string; /**< Cookie string for this fetch */
char *realm; /**< HTTP Auth Realm */
char *post_urlenc; /**< Url encoded POST string, or 0. */
@@ -365,6 +366,7 @@ struct fetch * fetch_start(char *url, char *referer,
fetch->host = host;
fetch->location = 0;
fetch->content_length = 0;
+ fetch->http_code = 0;
fetch->cookie_string = 0;
fetch->realm = 0;
fetch->post_urlenc = 0;
@@ -1034,6 +1036,23 @@ int fetch_curl_progress(void *clientp, double dltotal, double dlnow,
size_t fetch_curl_data(void *data, size_t size, size_t nmemb,
struct fetch *f)
{
+ /* ensure we only have to get this information once */
+ if (!f->http_code)
+ {
+ CURLcode code;
+ code = curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
+ &f->http_code);
+ assert(code == CURLE_OK);
+ }
+
+ /* ignore body if this is a 401 reply by skipping it and reset
+ the HTTP response code to enable follow up fetches */
+ if (f->http_code == 401)
+ {
+ f->http_code = 0;
+ return size * nmemb;
+ }
+
LOG(("fetch %p, size %u", f, size * nmemb));
if (f->abort || (!f->had_headers && fetch_process_headers(f))) {