2011-09-04 10:28:09 +04:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2017-03-19 18:00:21 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* MIME type sniffer interface
|
2011-09-04 10:28:09 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NETSURF_CONTENT_MIMESNIFF_H_
|
|
|
|
#define NETSURF_CONTENT_MIMESNIFF_H_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <libwapcaplet/libwapcaplet.h>
|
|
|
|
#include "utils/errors.h"
|
|
|
|
|
|
|
|
struct llcache_handle;
|
|
|
|
|
|
|
|
/**
|
2017-03-19 18:00:21 +03:00
|
|
|
* Compute the effective MIME type for an object
|
|
|
|
*
|
|
|
|
* The implementation uses the sniffing algorithm described in
|
|
|
|
* http://mimesniff.spec.whatwg.org/
|
2011-09-04 10:28:09 +04:00
|
|
|
*
|
2017-03-20 01:29:23 +03:00
|
|
|
* \param content_type_header Source content type header
|
2011-09-04 10:28:09 +04:00
|
|
|
* \param data First data chunk, or NULL
|
|
|
|
* \param len Length of \a data, in bytes
|
|
|
|
* \param sniff_allowed Whether MIME type sniffing is allowed
|
2012-02-08 04:52:16 +04:00
|
|
|
* \param image_only Sniff image types only
|
2011-09-04 10:28:09 +04:00
|
|
|
* \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
|
|
|
|
*/
|
2017-03-20 01:29:23 +03:00
|
|
|
nserror mimesniff_compute_effective_type(const char *content_type_header,
|
2011-09-04 10:28:09 +04:00
|
|
|
const uint8_t *data, size_t len, bool sniff_allowed,
|
2012-02-08 04:52:16 +04:00
|
|
|
bool image_only, lwc_string **effective_type);
|
2011-09-04 10:28:09 +04:00
|
|
|
|
|
|
|
#endif
|