summaryrefslogtreecommitdiff
path: root/content/fetch.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-08-28 20:04:35 +0000
committerJames Bursa <james@netsurf-browser.org>2003-08-28 20:04:35 +0000
commit3ce4ce9653fa2d5e68a7800a8943a9d2ace15bba (patch)
tree89795582970ec74940160a7cd95833b5b3459fd8 /content/fetch.c
parentcef8c477c396458269a91ee756fc711bed74d0f4 (diff)
downloadnetsurf-3ce4ce9653fa2d5e68a7800a8943a9d2ace15bba.tar.gz
netsurf-3ce4ce9653fa2d5e68a7800a8943a9d2ace15bba.tar.bz2
[project @ 2003-08-28 20:04:35 by bursa]
Use Content-Length to give percentage downloads. svn path=/import/netsurf/; revision=256
Diffstat (limited to 'content/fetch.c')
-rw-r--r--content/fetch.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/content/fetch.c b/content/fetch.c
index 68fdb6b89..eb79afae3 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -47,6 +47,7 @@ struct fetch
char *host;
int status_code;
char *location;
+ unsigned long content_length;
struct fetch *queue;
struct fetch *prev;
struct fetch *next;
@@ -145,6 +146,7 @@ struct fetch * fetch_start(char *url, char *referer,
if (uri->server != 0)
fetch->host = xstrdup(uri->server);
fetch->status_code = 0;
+ fetch->content_length = 0;
fetch->queue = 0;
fetch->prev = 0;
fetch->next = 0;
@@ -420,6 +422,12 @@ size_t fetch_curl_header(char * data, size_t size, size_t nmemb, struct fetch *f
f->location[i] == '\r' ||
f->location[i] == '\n'; i--)
f->location[i] = '\0';
+ } else if (15 < size && strncasecmp(data, "Content-Length:", 15) == 0) {
+ /* extract Content-Length header */
+ for (i = 15; data[i] == ' ' || data[i] == '\t'; i++)
+ ;
+ if ('0' <= data[i] && data[i] <= '9')
+ f->content_length = atol(data + i);
}
return size;
}
@@ -463,7 +471,7 @@ int fetch_process_headers(struct fetch *f)
}
LOG(("FETCH_TYPE, '%s'", type));
- f->callback(FETCH_TYPE, f->p, type, 0);
+ f->callback(FETCH_TYPE, f->p, type, f->content_length);
if (f->aborting) {
f->in_callback = 0;
return 1;