summaryrefslogtreecommitdiff
path: root/css/css.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-01-28 01:35:00 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-01-28 01:35:00 +0000
commit78d194cb77db00a530779aa2a1e8d2ef9707d229 (patch)
treeba4d25c396623825fcc020bf26cd757ca34f37ec /css/css.c
parent32fe1bd1bfcaa2c96cd407c3d1e20f2d4000bd0b (diff)
downloadnetsurf-78d194cb77db00a530779aa2a1e8d2ef9707d229.tar.gz
netsurf-78d194cb77db00a530779aa2a1e8d2ef9707d229.tar.bz2
Rework handling of HTTP redirects -- we now count the number of redirects followed for a given item and abort if a fixed limit is reached. This fixes sites which have pages that redirect to themselves.
Redirect handling is now transparent to clients of fetchcache. The new scheme works as follows: 1) Request content for URL (fetchcache() 2) Start fetch of content (fetchcache_go() 3) If no redirect, continue through LOADING, READY, DONE etc. states as before If redirect, receive NEWPTR for each redirect that occurs, then continue through LOADING, READY, DONE etc. states as before. The upshot of this is that redirects result in extra contents being created. It also means that, until LOADING has been received, the content (and thus the URL being fetched) may change. Therefore, fetchcache clients should expect to have to deal with transient data prior to LOADING occurring. As a necessary side-effect of this, the HTML object URLs and CSS @import URLs are no longer stored alongside the relevant contents. These URLs can be accessed by interrogating the url member of struct content anyway, so it was a rather redundant scheme before. svn path=/trunk/netsurf/; revision=3787
Diffstat (limited to 'css/css.c')
-rw-r--r--css/css.c40
1 files changed, 1 insertions, 39 deletions
diff --git a/css/css.c b/css/css.c
index 878be04cf..1853d272f 100644
--- a/css/css.c
+++ b/css/css.c
@@ -431,7 +431,6 @@ bool css_convert(struct content *c, int width, int height)
for (i = 0; i != HASH_SIZE; i++)
c->data.css.css->rule[i] = 0;
c->data.css.import_count = 0;
- c->data.css.import_url = 0;
c->data.css.import_content = 0;
c->data.css.origin = CSS_ORIGIN_UA;
c->active = 0;
@@ -504,11 +503,9 @@ void css_destroy(struct content *c)
/* imported stylesheets */
for (i = 0; i != c->data.css.import_count; i++)
if (c->data.css.import_content[i] != 0) {
- free(c->data.css.import_url[i]);
content_remove_user(c->data.css.import_content[i],
css_atimport_callback, (intptr_t) c, i);
}
- free(c->data.css.import_url);
free(c->data.css.import_content);
}
@@ -790,21 +787,11 @@ void css_atimport(struct content *c, struct css_node *node)
char *t, *url, *url1;
bool string = false, screen = true;
unsigned int i;
- char **import_url;
struct content **import_content;
url_func_result res;
LOG(("@import rule"));
- import_url = realloc(c->data.css.import_url,
- (c->data.css.import_count + 1) *
- sizeof(*c->data.css.import_url));
- if (!import_url) {
- /** \todo report to user */
- return;
- }
- c->data.css.import_url = import_url;
-
import_content = realloc(c->data.css.import_content,
(c->data.css.import_count + 1) *
sizeof(*c->data.css.import_content));
@@ -889,8 +876,7 @@ void css_atimport(struct content *c, struct css_node *node)
/* start the fetch */
c->data.css.import_count++;
i = c->data.css.import_count - 1;
- c->data.css.import_url[i] = url1;
- c->data.css.import_content[i] = fetchcache(c->data.css.import_url[i],
+ c->data.css.import_content[i] = fetchcache(url1,
css_atimport_callback, (intptr_t) c, i,
c->width, c->height, true, 0, 0, false, false);
if (c->data.css.import_content[i]) {
@@ -968,30 +954,6 @@ void css_atimport_callback(content_msg msg, struct content *css,
case CONTENT_MSG_STATUS:
break;
- case CONTENT_MSG_REDIRECT:
- c->active--;
- free(c->data.css.import_url[i]);
- c->data.css.import_url[i] = strdup(data.redirect);
- if (!c->data.css.import_url[i]) {
- /** \todo report to user */
- /* c->error = 1; */
- return;
- }
- c->data.css.import_content[i] = fetchcache(
- c->data.css.import_url[i],
- css_atimport_callback, (intptr_t) c, i,
- css->width, css->height, true, 0, 0,
- false, false);
- if (c->data.css.import_content[i]) {
- c->active++;
- fetchcache_go(c->data.css.import_content[i],
- c->url, css_atimport_callback,
- (intptr_t) c, i,
- css->width, css->height,
- 0, 0, false, c->url);
- }
- break;
-
case CONTENT_MSG_NEWPTR:
c->data.css.import_content[i] = css;
break;