From 54cd21ae0d9c8e1fa3e1642177aab98ebd4e74e7 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 3 Nov 2009 07:03:07 +0000 Subject: Realm may be NULL iff there's no WWW-Authenticate header served up with a 401. Default the realm to the fetch URL in this case. Fixes #2890933 Note for new cache implementation (which is actually capable of utilising response bodies in this situation): if there is no WWW-Authenticate header, serve up the response body immediately -- don't present an authentication dialogue. svn path=/trunk/netsurf/; revision=9659 --- content/fetchcache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'content') diff --git a/content/fetchcache.c b/content/fetchcache.c index 3c43e1f60..a763db193 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -1147,8 +1147,12 @@ void fetchcache_auth(struct content *c, const char *realm) char *headers = NULL; /* Preconditions */ - assert(c && realm); + assert(c); assert(c->status == CONTENT_STATUS_TYPE_UNKNOWN); + /* Realm may be NULL iff there was no WWW-Authenticate header + * Use the content's URL as the realm in this case */ + if (realm == NULL) + realm = c->url; /* Extract fetch details */ ref = fetch_get_referer(c->fetch); @@ -1179,7 +1183,7 @@ void fetchcache_auth(struct content *c, const char *realm) if (auth == NULL || c->tried_with_auth) { /* No authentication details or we tried what we had, so ask * our client for them. */ - c->tried_with_auth = false; /* Allow rety. */ + c->tried_with_auth = false; /* Allow retry. */ c->status = CONTENT_STATUS_ERROR; msg_data.auth_realm = realm; -- cgit v1.2.3