summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-05-30 11:09:50 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-05-30 11:09:50 +0000
commitf4be61553c38f980d38c7afd7b693def3ec5208c (patch)
tree93ecd5fe8277bfc4e9b09d44d6293c98235dc37d
parentae992eab4d58f35465976ddb7603f37573370b84 (diff)
downloadnetsurf-f4be61553c38f980d38c7afd7b693def3ec5208c.tar.gz
netsurf-f4be61553c38f980d38c7afd7b693def3ec5208c.tar.bz2
Fix handling of cache control data
svn path=/trunk/netsurf/; revision=4227
-rw-r--r--content/fetchcache.c13
-rw-r--r--content/fetchers/fetch_curl.c11
2 files changed, 17 insertions, 7 deletions
diff --git a/content/fetchcache.c b/content/fetchcache.c
index adfc9fac8..087354489 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -282,8 +282,17 @@ void fetchcache_go(struct content *content, const char *referer,
int i = 0;
char *etag = content->cache_data->etag;
time_t date = content->cache_data->date;
- content->cache_data->etag = 0;
+
+ content->cache_data->req_time = time(NULL);
+ content->cache_data->res_time = 0;
content->cache_data->date = 0;
+ content->cache_data->expires = 0;
+ content->cache_data->age = INVALID_AGE;
+ content->cache_data->max_age = INVALID_AGE;
+ content->cache_data->no_cache = false;
+ content->cache_data->etag = 0;
+ content->cache_data->last_modified = 0;
+
headers = malloc(3 * sizeof(char *));
if (!headers) {
content->status = CONTENT_STATUS_ERROR;
@@ -626,7 +635,7 @@ void fetchcache_parse_header(struct content *c, const char *data,
/* Set fetch response time if not already set */
if (c->cache_data->res_time == 0)
- c->cache_data->res_time = time(0);
+ c->cache_data->res_time = time(NULL);
if (5 < size && strncasecmp(data, "Date:", 5) == 0) {
/* extract Date header */
diff --git a/content/fetchers/fetch_curl.c b/content/fetchers/fetch_curl.c
index 7c2ca5c8d..465af2c9c 100644
--- a/content/fetchers/fetch_curl.c
+++ b/content/fetchers/fetch_curl.c
@@ -1132,11 +1132,12 @@ bool fetch_curl_process_headers(struct curl_fetch_info *f)
if (url_path && stat(url_path, &s) == 0) {
/* file: URL and file exists */
/* create etag */
- /*free(f->cachedata.etag);
- f->cachedata.etag = malloc(13);
- if (f->cachedata.etag)
- sprintf(f->cachedata.etag,
- "\"%10d\"", (int)s.st_mtime);*/
+ char etag_buf[20];
+ snprintf(etag_buf, sizeof etag_buf,
+ "ETag: \"%10d\"", (int) s.st_mtime);
+ /* And send it to the header handler */
+ fetch_send_callback(FETCH_HEADER, f->fetch_handle, etag_buf,
+ strlen(etag_buf));
/* don't set last modified time so as to ensure that local
* files are revalidated at all times. */