summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-02-03 12:04:48 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-02-03 12:04:48 +0000
commitad6fcea6b008638ca532436ecf8ba9fe7e41ffdd (patch)
tree7928f5211a6cd644dcfd764b1c67cf3f6b8ed121 /content
parenteb2c2e3f63056e7f8b992f17f94a9418ac311a0f (diff)
downloadnetsurf-ad6fcea6b008638ca532436ecf8ba9fe7e41ffdd.tar.gz
netsurf-ad6fcea6b008638ca532436ecf8ba9fe7e41ffdd.tar.bz2
Add url_fragment to extract fragment from URL
Optionally allow url_compare to ignore fragments in comparison Fix handling of url_compare result in a few places Fix redirects which contain fragments in the Location header svn path=/trunk/netsurf/; revision=3826
Diffstat (limited to 'content')
-rw-r--r--content/content.c1
-rw-r--r--content/content.h5
-rw-r--r--content/fetchcache.c18
3 files changed, 15 insertions, 9 deletions
diff --git a/content/content.c b/content/content.c
index c8389d80e..9310eb180 100644
--- a/content/content.c
+++ b/content/content.c
@@ -608,6 +608,7 @@ bool content_set_type(struct content *c, content_type type,
return false;
}
content_remove_user(c, callback, p1, p2);
+ msg_data.new_url = NULL;
content_broadcast(clone, CONTENT_MSG_NEWPTR, msg_data);
fetchcache_go(clone, referer,
callback, p1, p2,
diff --git a/content/content.h b/content/content.h
index 324af952f..7fb11ca2a 100644
--- a/content/content.h
+++ b/content/content.h
@@ -84,7 +84,7 @@ typedef enum {
CONTENT_MSG_STATUS, /**< new status string */
CONTENT_MSG_REFORMAT, /**< content_reformat done */
CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */
- CONTENT_MSG_NEWPTR, /**< address of structure has changed */
+ CONTENT_MSG_NEWPTR, /**< structure has been replaced */
CONTENT_MSG_REFRESH, /**< wants refresh */
#ifdef WITH_AUTH
CONTENT_MSG_AUTH, /**< authentication required */
@@ -97,7 +97,8 @@ typedef enum {
/** Extra data for some content_msg messages. */
union content_msg_data {
const char *error; /**< Error message, for CONTENT_MSG_ERROR. */
- char *redirect; /**< Redirect URL, for CONTENT_MSG_REDIRECT. */
+ const char *new_url; /**< Replacement URL (or NULL if the same
+ * as previous), for CONTENT_MSG_NEWPTR. */
/** Area of content which needs redrawing, for CONTENT_MSG_REDRAW. */
struct {
float x, y, width, height;
diff --git a/content/fetchcache.c b/content/fetchcache.c
index b6b17a618..4fdbb93ca 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -689,6 +689,8 @@ void fetchcache_notmodified(struct content *c, const void *data)
}
content_remove_user(c, callback, p1, p2);
+
+ msg_data.new_url = NULL;
callback(CONTENT_MSG_NEWPTR, fb, p1, p2, msg_data);
/* and catch user up with fallback's state */
@@ -786,25 +788,26 @@ void fetchcache_redirect(struct content *c, const void *data,
{
char *url, *url1;
char *referer, *parent_url;
- long http_code = fetch_http_code(c->fetch);
- const char *ref = fetch_get_referer(c->fetch);
- const char *parent = fetch_get_parent_url(c->fetch);
+ long http_code;
+ const char *ref;
+ const char *parent;
union content_msg_data msg_data;
url_func_result result;
/* Preconditions */
assert(c && data);
assert(c->status == CONTENT_STATUS_TYPE_UNKNOWN);
- /* Ensure a redirect happened */
- assert(300 <= http_code && http_code <= 399);
- /* 304 is handled by fetch_notmodified() */
- assert(http_code != 304);
/* Extract fetch details */
http_code = fetch_http_code(c->fetch);
ref = fetch_get_referer(c->fetch);
parent = fetch_get_parent_url(c->fetch);
+ /* Ensure a redirect happened */
+ assert(300 <= http_code && http_code <= 399);
+ /* 304 is handled by fetch_notmodified() */
+ assert(http_code != 304);
+
/* Clone referer and parent url
* originals are destroyed in fetch_abort() */
referer = ref ? strdup(ref) : NULL;
@@ -941,6 +944,7 @@ void fetchcache_redirect(struct content *c, const void *data,
replacement->redirect_count = c->redirect_count + 1;
/* Notify user that content has changed */
+ msg_data.new_url = url;
callback(CONTENT_MSG_NEWPTR, replacement, p1, p2, msg_data);
/* Start fetching the replacement content */