mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
[project @ 2003-07-16 17:38:46 by bursa]
Make fetchcache return 0 on failure to parse URL. svn path=/import/netsurf/; revision=225
This commit is contained in:
parent
6724b2c21e
commit
c7520629b0
@ -121,6 +121,7 @@ struct content * content_create(char *url)
|
||||
c->url = xstrdup(url);
|
||||
c->type = CONTENT_UNKNOWN;
|
||||
c->status = CONTENT_STATUS_TYPE_UNKNOWN;
|
||||
c->cache = 0;
|
||||
c->size = sizeof(struct content);
|
||||
c->fetch = 0;
|
||||
strcpy(c->status_message, "Loading");
|
||||
@ -178,6 +179,8 @@ void content_convert(struct content *c, unsigned long width, unsigned long heigh
|
||||
if (handler_map[c->type].convert(c, width, height)) {
|
||||
/* convert failed, destroy content */
|
||||
content_broadcast(c, CONTENT_MSG_ERROR, "Conversion failed");
|
||||
if (c->cache)
|
||||
cache_destroy(c);
|
||||
content_destroy(c);
|
||||
return;
|
||||
}
|
||||
@ -305,10 +308,13 @@ void content_remove_user(struct content *c,
|
||||
if (c->fetch != 0)
|
||||
fetch_abort(c->fetch);
|
||||
if (c->status < CONTENT_STATUS_READY) {
|
||||
cache_destroy(c);
|
||||
if (c->cache)
|
||||
cache_destroy(c);
|
||||
content_destroy(c);
|
||||
} else
|
||||
cache_freeable(c);
|
||||
} else {
|
||||
if (c->cache)
|
||||
cache_freeable(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,10 @@ struct fetch * fetch_start(char *url, char *referer,
|
||||
LOG(("fetch %p, url '%s'", fetch, url));
|
||||
|
||||
uri = xmlParseURI(url);
|
||||
assert(uri != 0);
|
||||
if (uri == 0) {
|
||||
LOG(("warning: failed to parse url"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* construct a new fetch structure */
|
||||
fetch->start_time = time(0);
|
||||
|
@ -46,6 +46,12 @@ struct content * fetchcache(const char *url0, char *referer,
|
||||
c->width = width;
|
||||
c->height = height;
|
||||
c->fetch = fetch_start(url, referer, fetchcache_callback, c);
|
||||
if (c->fetch == 0) {
|
||||
LOG(("warning: fetch_start failed"));
|
||||
cache_destroy(c);
|
||||
content_destroy(c);
|
||||
return 0;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,8 @@ void css_revive(struct content *c, unsigned int width, unsigned int height)
|
||||
c->data.css.import_url[i], c->url,
|
||||
css_atimport_callback, c, i,
|
||||
c->width, c->height);
|
||||
if (c->data.css.import_content[i] == 0)
|
||||
continue;
|
||||
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
}
|
||||
@ -296,7 +298,8 @@ void css_atimport(struct content *c, struct node *node)
|
||||
c->data.css.import_content[i] = fetchcache(
|
||||
c->data.css.import_url[i], c->url, css_atimport_callback,
|
||||
c, i, c->width, c->height);
|
||||
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
||||
if (c->data.css.import_content[i] &&
|
||||
c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
|
||||
free(url);
|
||||
@ -343,7 +346,8 @@ void css_atimport_callback(content_msg msg, struct content *css,
|
||||
c->data.css.import_content[i] = fetchcache(
|
||||
c->data.css.import_url[i], c->url, css_atimport_callback,
|
||||
c, i, css->width, css->height);
|
||||
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
||||
if (c->data.css.import_content[i] &&
|
||||
c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
break;
|
||||
|
||||
|
@ -40,10 +40,14 @@ int main(int argc, char *argv[])
|
||||
puts("=== URL:");
|
||||
gets(url);
|
||||
c = fetchcache(url, 0, callback, 0, 0, 100, 1000);
|
||||
done = c->status == CONTENT_STATUS_DONE;
|
||||
while (!done)
|
||||
fetch_poll();
|
||||
puts("=== SUCCESS, dumping cache");
|
||||
if (c) {
|
||||
done = c->status == CONTENT_STATUS_DONE;
|
||||
while (!done)
|
||||
fetch_poll();
|
||||
puts("=== SUCCESS, dumping cache");
|
||||
} else {
|
||||
puts("=== FAILURE, dumping cache");
|
||||
}
|
||||
cache_dump();
|
||||
content_remove_user(c, callback, 0, 0);
|
||||
}
|
||||
|
@ -230,6 +230,10 @@ void browser_window_open_location_historical(struct browser_window* bw, const ch
|
||||
bw->time0 = clock();
|
||||
bw->loading_content = fetchcache(url, 0, browser_window_callback, bw, 0,
|
||||
gui_window_get_width(bw->window), 0);
|
||||
if (bw->loading_content == 0) {
|
||||
browser_window_set_status(bw, "Unable to fetch document");
|
||||
return;
|
||||
}
|
||||
if (bw->loading_content->status == CONTENT_STATUS_READY)
|
||||
browser_window_callback(CONTENT_MSG_READY, bw->loading_content, bw, 0, 0);
|
||||
else if (bw->loading_content->status == CONTENT_STATUS_DONE)
|
||||
|
@ -176,7 +176,8 @@ void html_convert_css_callback(content_msg msg, struct content *css,
|
||||
c->data.html.stylesheet_content[i] = fetchcache(
|
||||
error, c->url, html_convert_css_callback,
|
||||
c, i, css->width, css->height);
|
||||
if (c->data.html.stylesheet_content[i]->status != CONTENT_STATUS_DONE)
|
||||
if (c->data.html.stylesheet_content[i] != 0 &&
|
||||
c->data.html.stylesheet_content[i]->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
break;
|
||||
|
||||
@ -228,6 +229,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
|
||||
c->url,
|
||||
html_convert_css_callback,
|
||||
c, 0, c->width, c->height);
|
||||
assert(c->data.html.stylesheet_content[0] != 0);
|
||||
if (c->data.html.stylesheet_content[0]->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
|
||||
@ -278,7 +280,8 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
|
||||
c->data.html.stylesheet_content[i] = fetchcache(url, c->url,
|
||||
html_convert_css_callback, c, i,
|
||||
c->width, c->height);
|
||||
if (c->data.html.stylesheet_content[i]->status != CONTENT_STATUS_DONE)
|
||||
if (c->data.html.stylesheet_content[i] &&
|
||||
c->data.html.stylesheet_content[i]->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
free(url);
|
||||
i++;
|
||||
@ -362,10 +365,12 @@ void html_fetch_object(struct content *c, char *url, struct box *box)
|
||||
c->width, c->height); /* we don't know the object's
|
||||
dimensions yet; use
|
||||
parent's as an estimate */
|
||||
c->active++;
|
||||
if (c->data.html.object[i].content->status == CONTENT_STATUS_DONE)
|
||||
html_object_callback(CONTENT_MSG_DONE,
|
||||
c->data.html.object[i].content, c, i, 0);
|
||||
if (c->data.html.object[i].content) {
|
||||
c->active++;
|
||||
if (c->data.html.object[i].content->status == CONTENT_STATUS_DONE)
|
||||
html_object_callback(CONTENT_MSG_DONE,
|
||||
c->data.html.object[i].content, c, i, 0);
|
||||
}
|
||||
c->data.html.object_count++;
|
||||
}
|
||||
|
||||
@ -453,7 +458,8 @@ void html_object_callback(content_msg msg, struct content *object,
|
||||
c->data.html.object[i].content = fetchcache(
|
||||
error, c->url, html_object_callback,
|
||||
c, i, 0, 0);
|
||||
if (c->data.html.object[i].content->status != CONTENT_STATUS_DONE)
|
||||
if (c->data.html.object[i].content &&
|
||||
c->data.html.object[i].content->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
break;
|
||||
|
||||
@ -519,7 +525,8 @@ void html_revive(struct content *c, unsigned int width, unsigned int height)
|
||||
c->data.html.object[i].url, c->url,
|
||||
html_object_callback,
|
||||
c, i, 0, 0);
|
||||
if (c->data.html.object[i].content->status != CONTENT_STATUS_DONE)
|
||||
if (c->data.html.object[i].content &&
|
||||
c->data.html.object[i].content->status != CONTENT_STATUS_DONE)
|
||||
c->active++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user