summaryrefslogtreecommitdiff
path: root/content/llcache.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-02-24 10:14:50 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-02-24 10:14:50 +0000
commit6b26f77bb17c92294824f252491d93ee4811f4b4 (patch)
treee40da51ebd6d38dd3fd5e4a9e1c4b56a1e274f40 /content/llcache.c
parentc74936c3e81adc33db8ad84b31e8f676fd2e73dc (diff)
downloadnetsurf-6b26f77bb17c92294824f252491d93ee4811f4b4.tar.gz
netsurf-6b26f77bb17c92294824f252491d93ee4811f4b4.tar.bz2
Use cache control data invalidation function everywhere we want the cache control data reset.
Fix cache control data invalidation to reset the age and max_age fields to INVALID_AGE. Fix cache control data reset on encountering an HTTP response line to occur before we fill in the response time, rather than after it. svn path=/trunk/netsurf/; revision=11783
Diffstat (limited to 'content/llcache.c')
-rw-r--r--content/llcache.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/content/llcache.c b/content/llcache.c
index 1ad8b8452..5673a377f 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -229,6 +229,9 @@ static inline void llcache_invalidate_cache_control_data(llcache_object *object)
{
free(object->cache.etag);
memset(&(object->cache), 0, sizeof(llcache_cache_control));
+
+ object->cache.age = INVALID_AGE;
+ object->cache.max_age = INVALID_AGE;
}
@@ -1083,16 +1086,8 @@ nserror llcache_object_refetch(llcache_object *object)
headers[header_idx] = NULL;
/* Reset cache control data */
+ llcache_invalidate_cache_control_data(object);
object->cache.req_time = time(NULL);
- object->cache.res_time = 0;
- object->cache.date = 0;
- object->cache.expires = 0;
- object->cache.age = INVALID_AGE;
- object->cache.max_age = INVALID_AGE;
- object->cache.no_cache = false;
- free(object->cache.etag);
- object->cache.etag = NULL;
- object->cache.last_modified = 0;
/* Reset fetch state */
object->fetch.state = LLCACHE_FETCH_INIT;
@@ -2219,6 +2214,10 @@ nserror llcache_fetch_split_header(const char *data, size_t len, char **name,
* \param name Pointer to location to receive header name
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
+ *
+ * \note This function also has the side-effect of updating
+ * the cache control data for the object if an interesting
+ * header is encountered
*/
nserror llcache_fetch_parse_header(llcache_object *object, const char *data,
size_t len, char **name, char **value)
@@ -2319,10 +2318,6 @@ nserror llcache_fetch_process_header(llcache_object *object, const char *data,
char *name, *value;
llcache_header *temp;
- error = llcache_fetch_parse_header(object, data, len, &name, &value);
- if (error != NSERROR_OK)
- return error;
-
/* The headers for multiple HTTP responses may be delivered to us if
* the fetch layer receives a 401 response for which it has
* authentication credentials. This will result in a silent re-request
@@ -2334,7 +2329,8 @@ nserror llcache_fetch_process_header(llcache_object *object, const char *data,
* must discard any headers we've read so far, reset the cache data
* that we might have computed, and start again.
*/
- if (strncmp(name, "HTTP/", SLEN("HTTP/")) == 0 && value[0] == '\0') {
+ /** \todo Properly parse the response line */
+ if (strncmp(data, "HTTP/", SLEN("HTTP/")) == 0) {
time_t req_time = object->cache.req_time;
llcache_invalidate_cache_control_data(object);
@@ -2345,6 +2341,10 @@ nserror llcache_fetch_process_header(llcache_object *object, const char *data,
llcache_destroy_headers(object);
}
+ error = llcache_fetch_parse_header(object, data, len, &name, &value);
+ if (error != NSERROR_OK)
+ return error;
+
/* Append header data to the object's headers array */
temp = realloc(object->headers, (object->num_headers + 1) *
sizeof(llcache_header));