diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2019-06-10 21:35:36 +0000 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2019-06-10 21:35:36 +0000 |
commit | 23698aecf844c105b210fa42b642c1d0203978c9 (patch) | |
tree | f89a2d6269919ac3ab519aaff454da63c2eb8c59 /utils/http/cache-control.c | |
parent | 047c82cfce53102aced0f76f5ca13fe3c56b4db2 (diff) | |
download | netsurf-23698aecf844c105b210fa42b642c1d0203978c9.tar.gz netsurf-23698aecf844c105b210fa42b642c1d0203978c9.tar.bz2 |
HTTP: expose validity of max-age in Cache-Control
As max-age is an optional directive, provide a means to determine
if it is present and correct.
Diffstat (limited to 'utils/http/cache-control.c')
-rw-r--r-- | utils/http/cache-control.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/utils/http/cache-control.c b/utils/http/cache-control.c index f348f1614..44700821d 100644 --- a/utils/http/cache-control.c +++ b/utils/http/cache-control.c @@ -30,6 +30,7 @@ */ struct http_cache_control { uint32_t max_age; /**< Max age (delta seconds) */ + bool max_age_valid; /**< Whether max-age is valid */ bool no_cache; /**< Whether caching is forbidden */ bool no_store; /**< Whether persistent caching is forbidden */ }; @@ -240,6 +241,7 @@ nserror http_parse_cache_control(const char *header_value, http_directive *directives = NULL; lwc_string *value_str = NULL; uint32_t max_age = 0; + bool max_age_valid = false; bool no_cache = false; bool no_store = false; nserror error; @@ -279,6 +281,7 @@ nserror http_parse_cache_control(const char *header_value, corestring_lwc_max_age, &value_str); if (error == NSERROR_OK && value_str != NULL) { error = parse_max_age(value_str, &max_age); + max_age_valid = (error == NSERROR_OK); lwc_string_unref(value_str); } @@ -310,6 +313,7 @@ nserror http_parse_cache_control(const char *header_value, } cc->max_age = max_age; + cc->max_age_valid = max_age_valid; cc->no_cache = no_cache; cc->no_store = no_store; @@ -325,6 +329,12 @@ void http_cache_control_destroy(http_cache_control *victim) } /* See cache-control.h for documentation */ +bool http_cache_control_has_max_age(http_cache_control *cc) +{ + return cc->max_age_valid; +} + +/* See cache-control.h for documentation */ uint32_t http_cache_control_max_age(http_cache_control *cc) { return cc->max_age; |