summaryrefslogtreecommitdiff
path: root/utils/http/cache-control.h
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2019-06-10 20:52:15 +0000
committerJohn-Mark Bell <jmb@netsurf-browser.org>2019-06-10 21:02:19 +0000
commit04b790643b9e45a1ba8919481f3c4beb80a66c31 (patch)
treecf04d0e2d9609a50aa3a07a63a43983d54374a98 /utils/http/cache-control.h
parent9893b05b084980ff498eee6dd17853d8df807f27 (diff)
downloadnetsurf-04b790643b9e45a1ba8919481f3c4beb80a66c31.tar.gz
netsurf-04b790643b9e45a1ba8919481f3c4beb80a66c31.tar.bz2
HTTP: add minimal parser for Cache-Control
Diffstat (limited to 'utils/http/cache-control.h')
-rw-r--r--utils/http/cache-control.h69
1 files changed, 69 insertions, 0 deletions
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 <jmb@netsurf-browser.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NETSURF_UTILS_HTTP_CACHE_CONTROL_H_
+#define NETSURF_UTILS_HTTP_CACHE_CONTROL_H_
+
+#include <libwapcaplet/libwapcaplet.h>
+
+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