summaryrefslogtreecommitdiff
path: root/content/fetch.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-02-19 18:26:23 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-02-19 18:26:23 +0000
commit5ce5fe084c733c95544825e35bcd63cc775aee94 (patch)
tree23a1fae1a862e20c891c576325731963dbeaef39 /content/fetch.c
parent7dbc14cf05a7417f372fdda22f20622f8f72175f (diff)
downloadnetsurf-5ce5fe084c733c95544825e35bcd63cc775aee94.tar.gz
netsurf-5ce5fe084c733c95544825e35bcd63cc775aee94.tar.bz2
[project @ 2006-02-19 18:26:23 by jmb]
Rewrite HTTP authentication. Fix extraction of realm from WWW-Authenticate header. Tidy up login dialog code. svn path=/import/netsurf/; revision=2085
Diffstat (limited to 'content/fetch.c')
-rw-r--r--content/fetch.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/content/fetch.c b/content/fetch.c
index b63bf5f91..0d9ccd583 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -31,11 +31,11 @@
#endif
#include "curl/curl.h"
#include "netsurf/utils/config.h"
-#include "netsurf/content/fetch.h"
-#include "netsurf/desktop/options.h"
#ifdef WITH_AUTH
-#include "netsurf/desktop/401login.h"
+#include "netsurf/content/authdb.h"
#endif
+#include "netsurf/content/fetch.h"
+#include "netsurf/desktop/options.h"
#include "netsurf/render/form.h"
#define NDEBUG
#include "netsurf/utils/log.h"
@@ -414,7 +414,7 @@ failed:
CURLcode fetch_set_options(struct fetch *f)
{
CURLcode code;
- struct login *li;
+ const char *auth;
#undef SETOPT
#define SETOPT(option, value) \
@@ -445,12 +445,16 @@ CURLcode fetch_set_options(struct fetch *f)
SETOPT(CURLOPT_COOKIEFILE, 0);
SETOPT(CURLOPT_COOKIEJAR, 0);
}
- if ((li = login_list_get(f->url)) != NULL) {
+#ifdef WITH_AUTH
+ if ((auth = authdb_get(f->url)) != NULL) {
SETOPT(CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- SETOPT(CURLOPT_USERPWD, li->logindetails);
+ SETOPT(CURLOPT_USERPWD, auth);
} else {
+#endif
SETOPT(CURLOPT_USERPWD, 0);
+#ifdef WITH_AUTH
}
+#endif
if (option_http_proxy && option_http_proxy_host) {
SETOPT(CURLOPT_PROXY, option_http_proxy_host);
SETOPT(CURLOPT_PROXYPORT, (long) option_http_proxy_port);
@@ -796,8 +800,13 @@ size_t fetch_curl_header(char *data, size_t size, size_t nmemb,
return size;
}
SKIP_ST(17);
- while (i < (int)size && data[++i] == '"')
+
+ while (i < (int) size && strncasecmp(data + i, "realm", 5))
+ i++;
+ while (i < (int)size && data[++i] != '"')
/* */;
+ i++;
+
strncpy(f->realm, data + i, size - i);
f->realm[size - i] = '\0';
for (i = size - i - 1; i >= 0 &&