diff options
-rw-r--r-- | content/fetchcache.c | 13 | ||||
-rw-r--r-- | content/fetchers/fetch_curl.c | 11 |
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. */ |