diff options
author | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2010-03-28 12:56:39 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2010-03-28 12:56:39 +0000 |
commit | 270ef59a98d34fef418fb6cd27e46f3edc912948 (patch) | |
tree | 9d363b42d441640e1d2dbff3ba548a2cdf8d67a9 /utils/http.h | |
parent | 21da4f5bdf74c6654730c32dfcc1c6b3d24da4b4 (diff) | |
download | netsurf-270ef59a98d34fef418fb6cd27e46f3edc912948.tar.gz netsurf-270ef59a98d34fef418fb6cd27e46f3edc912948.tar.bz2 |
Merge jmb/new-cache; r=dsilvers,rs=vince
svn path=/trunk/netsurf/; revision=10180
Diffstat (limited to 'utils/http.h')
-rw-r--r-- | utils/http.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/utils/http.h b/utils/http.h new file mode 100644 index 000000000..1d8b4de6c --- /dev/null +++ b/utils/http.h @@ -0,0 +1,73 @@ +/* + * Copyright 2010 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 + * HTTP header parsing functions + */ + +#ifndef NETSURF_UTILS_HTTP_H_ +#define NETSURF_UTILS_HTTP_H_ + +#include "utils/errors.h" + +typedef struct http_parameter http_parameter; + +/** + * Parse an HTTP Content-Type header value + * + * \param header_value Header value to parse + * \param media_type Pointer to location to receive media type + * \param parameters Pointer to location to receive parameter list + * \return NSERROR_OK on success, + * NSERROR_NOMEM on memory exhaustion + */ +nserror http_parse_content_type(const char *header_value, char **media_type, + http_parameter **parameters); + +/** + * Find a named item in an HTTP parameter list + * + * \param list List to search + * \param name Name of item to search for + * \param value Pointer to location to receive value + * \return NSERROR_OK on success, + * NSERROR_NOT_FOUND if requested item does not exist + */ +nserror http_parameter_list_find_item(const http_parameter *list, + const char *name, const char **value); + +/** + * Iterate over a parameter list + * + * \param cur Pointer to current iteration position, list head to start + * \param name Pointer to location to receive item name + * \param value Pointer to location to receive item value + * \return Pointer to next iteration position, or NULL for end of iteration + */ +const http_parameter *http_parameter_list_iterate(const http_parameter *cur, + const char **name, const char **value); + +/** + * Destroy a list of HTTP parameters + * + * \param list List to destroy + */ +void http_parameter_list_destroy(http_parameter *list); + +#endif + |