From c9e188a4d1634d9c7d2292a8d04e02f313f37f3b Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 25 Oct 2003 19:20:13 +0000 Subject: [project @ 2003-10-25 19:20:13 by jmb] HTTP Auth login improved (greatly). Addresses all three issues in the previous version. svn path=/import/netsurf/; revision=382 --- content/content.h | 3 ++- content/fetch.c | 15 +++++---------- content/fetch.h | 2 +- content/fetchcache.c | 8 ++++++++ 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'content') diff --git a/content/content.h b/content/content.h index 249e21192..72034b316 100644 --- a/content/content.h +++ b/content/content.h @@ -71,7 +71,8 @@ typedef enum { CONTENT_MSG_ERROR, /**< error occurred */ CONTENT_MSG_STATUS, /**< new status string */ CONTENT_MSG_REDIRECT, /**< replacement URL */ - CONTENT_MSG_REFORMAT /**< content_reformat done */ + CONTENT_MSG_REFORMAT, /**< content_reformat done */ + CONTENT_MSG_AUTH /**< authentication required */ } content_msg; /** Linked list of users of a content. */ diff --git a/content/fetch.c b/content/fetch.c index b7f48b506..391aa14d3 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -150,6 +150,7 @@ struct fetch * fetch_start(char *url, char *referer, CURLcode code; CURLMcode codem; xmlURI *uri; + struct login *li; LOG(("fetch %p, url '%s'", fetch, url)); @@ -268,12 +269,11 @@ struct fetch * fetch_start(char *url, char *referer, code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); assert(code == CURLE_OK); -#ifdef riscos - if (LOGIN.string != NULL) { - code = curl_easy_setopt(fetch->curl_handle, CURLOPT_USERPWD, LOGIN.string); + if ((li=login_list_get(url)) != NULL) { + code = curl_easy_setopt(fetch->curl_handle, CURLOPT_USERPWD, li->logindetails); + assert(code == CURLE_OK); } -#endif /* POST */ if (fetch->post_urlenc) { @@ -545,16 +545,11 @@ bool fetch_process_headers(struct fetch *f) return true; } -#ifdef riscos /* handle HTTP 401 (Authentication errors) */ if (http_code == 401) { - /* this shouldn't be here... */ - ro_gui_401login_open(xstrdup(f->host), xstrdup(f->realm), - xstrdup(f->url)); - f->callback(FETCH_ERROR, f->p, "",0); + f->callback(FETCH_AUTH, f->p, xstrdup(f->realm),0); return true; } -#endif /* handle HTTP errors (non 2xx response codes) */ if (f->only_2xx && strncmp(f->url, "http", 4) == 0 && diff --git a/content/fetch.h b/content/fetch.h index 762664923..492645df9 100644 --- a/content/fetch.h +++ b/content/fetch.h @@ -14,7 +14,7 @@ #include -typedef enum {FETCH_TYPE, FETCH_DATA, FETCH_FINISHED, FETCH_ERROR, FETCH_REDIRECT} fetch_msg; +typedef enum {FETCH_TYPE, FETCH_DATA, FETCH_FINISHED, FETCH_ERROR, FETCH_REDIRECT, FETCH_AUTH} fetch_msg; struct content; struct fetch; diff --git a/content/fetchcache.c b/content/fetchcache.c index 13ddbc9c5..28c098034 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -154,6 +154,14 @@ void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned long size) content_destroy(c); break; + case FETCH_AUTH: + /* data -> string containing the Realm */ + LOG(("FETCH_AUTH, '%s'", data)); + c->fetch = 0; + content_broadcast(c, CONTENT_MSG_AUTH, data); + cache_destroy(c); + break; + default: assert(0); } -- cgit v1.2.3