summaryrefslogtreecommitdiff
path: root/content/mimesniff.h
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-09-04 06:28:09 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-09-04 06:28:09 +0000
commit6807fa854da64166e84efd0074b1e4dfeb5d8b17 (patch)
tree998672af3a94f2eac0434cc138efa151ebcd603b /content/mimesniff.h
parent9ee4f6146e06f6d142cc98a2bc600a49b4a3ddc6 (diff)
downloadnetsurf-6807fa854da64166e84efd0074b1e4dfeb5d8b17.tar.gz
netsurf-6807fa854da64166e84efd0074b1e4dfeb5d8b17.tar.bz2
Sniff content types where appropriate.
We never sniff for CSS, nor for non-page artefacts (e.g. treeview icons) svn path=/trunk/netsurf/; revision=12707
Diffstat (limited to 'content/mimesniff.h')
-rw-r--r--content/mimesniff.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/content/mimesniff.h b/content/mimesniff.h
new file mode 100644
index 000000000..8ddabd2e7
--- /dev/null
+++ b/content/mimesniff.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011 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/>.
+ */
+
+/** \file
+ * MIME type sniffer (interface)
+ */
+
+#ifndef NETSURF_CONTENT_MIMESNIFF_H_
+#define NETSURF_CONTENT_MIMESNIFF_H_
+
+#include <stdbool.h>
+
+#include <libwapcaplet/libwapcaplet.h>
+#include "utils/errors.h"
+
+struct llcache_handle;
+
+/**
+ * Compute the effective MIME type for an object using the sniffing
+ * algorithm described in draft-abarth-mime-sniff-06.
+ *
+ * \param handle Source data handle to sniff
+ * \param data First data chunk, or NULL
+ * \param len Length of \a data, in bytes
+ * \param sniff_allowed Whether MIME type sniffing is allowed
+ * \param effective_type Location to receive computed type
+ * \return NSERROR_OK on success,
+ * NSERROR_NEED_DATA iff \a data is NULL and data is needed
+ * NSERROR_NOT_FOUND if sniffing is prohibited and no
+ * Content-Type header was found
+ */
+nserror mimesniff_compute_effective_type(struct llcache_handle *handle,
+ const uint8_t *data, size_t len, bool sniff_allowed,
+ lwc_string **effective_type);
+
+nserror mimesniff_init(void);
+void mimesniff_fini(void);
+
+#endif