From 04b790643b9e45a1ba8919481f3c4beb80a66c31 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Mon, 10 Jun 2019 20:52:15 +0000 Subject: HTTP: add minimal parser for Cache-Control --- utils/http/cache-control.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 utils/http/cache-control.h (limited to 'utils/http/cache-control.h') diff --git a/utils/http/cache-control.h b/utils/http/cache-control.h new file mode 100644 index 000000000..22c5f97ac --- /dev/null +++ b/utils/http/cache-control.h @@ -0,0 +1,69 @@ +/* + * Copyright 2019 John-Mark Bell + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NETSURF_UTILS_HTTP_CACHE_CONTROL_H_ +#define NETSURF_UTILS_HTTP_CACHE_CONTROL_H_ + +#include + +typedef struct http_cache_control http_cache_control; + +/** + * Parse an HTTP Cache-Control header value + * + * \param header_value Header value to parse + * \param result Pointer to location to receive result + * \return NSERROR_OK on success, + * NSERROR_NOMEM on memory exhaustion, + * appropriate error otherwise + */ +nserror http_parse_cache_control(const char *header_value, + http_cache_control **result); + +/** + * Destroy a cache_control object + * + * \param victim Object to destroy + */ +void http_cache_control_destroy(http_cache_control *victim); + +/** + * Get the value of a cache control's max-age + * + * \param cc Object to inspect + * \return Max age, in delta-seconds + */ +uint32_t http_cache_control_max_age(http_cache_control *cc); + +/** + * Get the value of a cache control's no-cache flag + * + * \param cc Object to inspect + * \return Whether caching is forbidden + */ +bool http_cache_control_no_cache(http_cache_control *cc); + +/** + * Get the value of a cache control's no-store flag + * + * \param cc Object to inspect + * \return Whether persistent caching is forbidden + */ +bool http_cache_control_no_store(http_cache_control *cc); + +#endif -- cgit v1.2.3