From 6807fa854da64166e84efd0074b1e4dfeb5d8b17 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 4 Sep 2011 06:28:09 +0000 Subject: 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 --- content/mimesniff.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 content/mimesniff.h (limited to 'content/mimesniff.h') 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 + * + * 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 . + */ + +/** \file + * MIME type sniffer (interface) + */ + +#ifndef NETSURF_CONTENT_MIMESNIFF_H_ +#define NETSURF_CONTENT_MIMESNIFF_H_ + +#include + +#include +#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 -- cgit v1.2.3