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->url = xstrdup(url);
|
||||||
c->type = CONTENT_UNKNOWN;
|
c->type = CONTENT_UNKNOWN;
|
||||||
c->status = CONTENT_STATUS_TYPE_UNKNOWN;
|
c->status = CONTENT_STATUS_TYPE_UNKNOWN;
|
||||||
|
c->cache = 0;
|
||||||
c->size = sizeof(struct content);
|
c->size = sizeof(struct content);
|
||||||
c->fetch = 0;
|
c->fetch = 0;
|
||||||
strcpy(c->status_message, "Loading");
|
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)) {
|
if (handler_map[c->type].convert(c, width, height)) {
|
||||||
/* convert failed, destroy content */
|
/* convert failed, destroy content */
|
||||||
content_broadcast(c, CONTENT_MSG_ERROR, "Conversion failed");
|
content_broadcast(c, CONTENT_MSG_ERROR, "Conversion failed");
|
||||||
|
if (c->cache)
|
||||||
|
cache_destroy(c);
|
||||||
content_destroy(c);
|
content_destroy(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -305,10 +308,13 @@ void content_remove_user(struct content *c,
|
|||||||
if (c->fetch != 0)
|
if (c->fetch != 0)
|
||||||
fetch_abort(c->fetch);
|
fetch_abort(c->fetch);
|
||||||
if (c->status < CONTENT_STATUS_READY) {
|
if (c->status < CONTENT_STATUS_READY) {
|
||||||
cache_destroy(c);
|
if (c->cache)
|
||||||
|
cache_destroy(c);
|
||||||
content_destroy(c);
|
content_destroy(c);
|
||||||
} else
|
} else {
|
||||||
cache_freeable(c);
|
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));
|
LOG(("fetch %p, url '%s'", fetch, url));
|
||||||
|
|
||||||
uri = xmlParseURI(url);
|
uri = xmlParseURI(url);
|
||||||
assert(uri != 0);
|
if (uri == 0) {
|
||||||
|
LOG(("warning: failed to parse url"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* construct a new fetch structure */
|
/* construct a new fetch structure */
|
||||||
fetch->start_time = time(0);
|
fetch->start_time = time(0);
|
||||||
|
@ -46,6 +46,12 @@ struct content * fetchcache(const char *url0, char *referer,
|
|||||||
c->width = width;
|
c->width = width;
|
||||||
c->height = height;
|
c->height = height;
|
||||||
c->fetch = fetch_start(url, referer, fetchcache_callback, c);
|
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;
|
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,
|
c->data.css.import_url[i], c->url,
|
||||||
css_atimport_callback, c, i,
|
css_atimport_callback, c, i,
|
||||||
c->width, c->height);
|
c->width, c->height);
|
||||||
|
if (c->data.css.import_content[i] == 0)
|
||||||
|
continue;
|
||||||
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
|
||||||
c->active++;
|
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_content[i] = fetchcache(
|
||||||
c->data.css.import_url[i], c->url, css_atimport_callback,
|
c->data.css.import_url[i], c->url, css_atimport_callback,
|
||||||
c, i, c->width, c->height);
|
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++;
|
c->active++;
|
||||||
|
|
||||||
free(url);
|
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_content[i] = fetchcache(
|
||||||
c->data.css.import_url[i], c->url, css_atimport_callback,
|
c->data.css.import_url[i], c->url, css_atimport_callback,
|
||||||
c, i, css->width, css->height);
|
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++;
|
c->active++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -40,10 +40,14 @@ int main(int argc, char *argv[])
|
|||||||
puts("=== URL:");
|
puts("=== URL:");
|
||||||
gets(url);
|
gets(url);
|
||||||
c = fetchcache(url, 0, callback, 0, 0, 100, 1000);
|
c = fetchcache(url, 0, callback, 0, 0, 100, 1000);
|
||||||
done = c->status == CONTENT_STATUS_DONE;
|
if (c) {
|
||||||
while (!done)
|
done = c->status == CONTENT_STATUS_DONE;
|
||||||
fetch_poll();
|
while (!done)
|
||||||
puts("=== SUCCESS, dumping cache");
|
fetch_poll();
|
||||||
|
puts("=== SUCCESS, dumping cache");
|
||||||
|
} else {
|
||||||
|
puts("=== FAILURE, dumping cache");
|
||||||
|
}
|
||||||
cache_dump();
|
cache_dump();
|
||||||
content_remove_user(c, callback, 0, 0);
|
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->time0 = clock();
|
||||||
bw->loading_content = fetchcache(url, 0, browser_window_callback, bw, 0,
|
bw->loading_content = fetchcache(url, 0, browser_window_callback, bw, 0,
|
||||||
gui_window_get_width(bw->window), 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)
|
if (bw->loading_content->status == CONTENT_STATUS_READY)
|
||||||
browser_window_callback(CONTENT_MSG_READY, bw->loading_content, bw, 0, 0);
|
browser_window_callback(CONTENT_MSG_READY, bw->loading_content, bw, 0, 0);
|
||||||
else if (bw->loading_content->status == CONTENT_STATUS_DONE)
|
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(
|
c->data.html.stylesheet_content[i] = fetchcache(
|
||||||
error, c->url, html_convert_css_callback,
|
error, c->url, html_convert_css_callback,
|
||||||
c, i, css->width, css->height);
|
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++;
|
c->active++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -228,6 +229,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head)
|
|||||||
c->url,
|
c->url,
|
||||||
html_convert_css_callback,
|
html_convert_css_callback,
|
||||||
c, 0, c->width, c->height);
|
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)
|
if (c->data.html.stylesheet_content[0]->status != CONTENT_STATUS_DONE)
|
||||||
c->active++;
|
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,
|
c->data.html.stylesheet_content[i] = fetchcache(url, c->url,
|
||||||
html_convert_css_callback, c, i,
|
html_convert_css_callback, c, i,
|
||||||
c->width, c->height);
|
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++;
|
c->active++;
|
||||||
free(url);
|
free(url);
|
||||||
i++;
|
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
|
c->width, c->height); /* we don't know the object's
|
||||||
dimensions yet; use
|
dimensions yet; use
|
||||||
parent's as an estimate */
|
parent's as an estimate */
|
||||||
c->active++;
|
if (c->data.html.object[i].content) {
|
||||||
if (c->data.html.object[i].content->status == CONTENT_STATUS_DONE)
|
c->active++;
|
||||||
html_object_callback(CONTENT_MSG_DONE,
|
if (c->data.html.object[i].content->status == CONTENT_STATUS_DONE)
|
||||||
c->data.html.object[i].content, c, i, 0);
|
html_object_callback(CONTENT_MSG_DONE,
|
||||||
|
c->data.html.object[i].content, c, i, 0);
|
||||||
|
}
|
||||||
c->data.html.object_count++;
|
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(
|
c->data.html.object[i].content = fetchcache(
|
||||||
error, c->url, html_object_callback,
|
error, c->url, html_object_callback,
|
||||||
c, i, 0, 0);
|
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++;
|
c->active++;
|
||||||
break;
|
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,
|
c->data.html.object[i].url, c->url,
|
||||||
html_object_callback,
|
html_object_callback,
|
||||||
c, i, 0, 0);
|
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++;
|
c->active++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user