⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpparser.h

📁 Upnp开发包文件
💻 H
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////// Copyright (c) 2000-2003 Intel Corporation // All rights reserved. //// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: //// * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither name of Intel Corporation nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission.// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE./////////////////////////////////////////////////////////////////////////////#ifndef GENLIB_NET_HTTP_HTTPPARSER_H#define GENLIB_NET_HTTP_HTTPPARSER_H#include "util.h"#include "membuffer.h"#include "uri.h"#include "LinkedList.h"////// private types //////////////////////////////////// scanner///////////////////////// Used to represent different types of tokens in inputtypedef enum // token_type_t{	TT_IDENTIFIER, 	TT_WHITESPACE, 	TT_CRLF, 	TT_CTRL,				// needed ??	TT_SEPARATOR,			// ??	TT_QUOTEDSTRING,		// ??} token_type_t;typedef struct // scanner_t{	membuffer* msg;				// raw http msg	size_t cursor;				// current position in buffer	xboolean entire_msg_loaded;	// set this to TRUE if the entire msg is loaded in								//   in 'msg'; else FALSE if only partial msg in 'msg'								//   (default is FALSE)} scanner_t;typedef enum // parser_pos_t{	POS_REQUEST_LINE,	POS_RESPONSE_LINE,	POS_HEADERS,	POS_ENTITY,	POS_COMPLETE,} parser_pos_t;#define ENTREAD_DETERMINE_READ_METHOD	1#define ENTREAD_USING_CLEN				2#define ENTREAD_USING_CHUNKED			3#define ENTREAD_UNTIL_CLOSE				4#define ENTREAD_CHUNKY_BODY				5#define ENTREAD_CHUNKY_HEADERS			6// end of private section//////////////////// ##################################################################################// method in a HTTP requesttypedef enum // http_method_t{	HTTPMETHOD_POST, 	HTTPMETHOD_MPOST, 	HTTPMETHOD_SUBSCRIBE, 	HTTPMETHOD_UNSUBSCRIBE, 	HTTPMETHOD_NOTIFY, 	HTTPMETHOD_GET,	HTTPMETHOD_HEAD, 	HTTPMETHOD_MSEARCH, 	HTTPMETHOD_UNKNOWN,    SOAPMETHOD_POST,	 //murari	HTTPMETHOD_SIMPLEGET} http_method_t;// different types of HTTP headers#define HDR_UNKNOWN				-1#define HDR_CACHE_CONTROL		1#define HDR_CALLBACK			2#define HDR_CONTENT_LENGTH		3#define HDR_CONTENT_TYPE		4#define HDR_DATE				5#define HDR_EXT					6#define HDR_HOST				7//#define HDR_IF_MODIFIED_SINCE	8//#define HDR_IF_UNMODIFIED_SINCE	9//#define HDR_LAST_MODIFIED		10#define HDR_LOCATION			11#define HDR_MAN					12#define HDR_MX					13#define HDR_NT					14#define HDR_NTS					15#define HDR_SERVER				16#define HDR_SEQ					17#define HDR_SID					18#define HDR_SOAPACTION			19#define HDR_ST					20#define HDR_TIMEOUT				21#define HDR_TRANSFER_ENCODING	22#define HDR_USN					23#define HDR_USER_AGENT			24//Adding new header difinition//Beg_Murari#define HDR_ACCEPT              25#define HDR_ACCEPT_ENCODING     26#define HDR_ACCEPT_CHARSET      27#define HDR_ACCEPT_LANGUAGE     28#define HDR_ACCEPT_RANGE        29#define HDR_CONTENT_ENCODING    30#define HDR_CONTENT_LANGUAGE    31#define HDR_CONTENT_LOCATION    32#define HDR_CONTENT_RANGE       33#define HDR_IF_RANGE            34#define HDR_RANGE               35#define HDR_TE                  36//End_Murari// status of parsingtypedef enum // parse_status_t{	PARSE_SUCCESS = 0,	// msg was parsed successfully	PARSE_INCOMPLETE,	// need more data to continue	PARSE_INCOMPLETE_ENTITY,	// for responses that don't have length specified	PARSE_FAILURE,		// parse failed; check status code for details	PARSE_OK,			// done partial	PARSE_NO_MATCH,		// token not matched	// private	PARSE_CONTINUE_1} parse_status_t;typedef struct // http_header_t{	memptr name;		// header name as a string	int name_id;		// header name id (for a selective group of headers only)	membuffer value;	// raw-value; could be multi-lined; min-length = 0    // private    membuffer name_buf;} http_header_t;typedef struct // http_message_t{    int initialized;	// request only	http_method_t method;	uri_type uri;	// response only	http_method_t request_method;	int status_code;	membuffer status_msg;	// fields used in both request or response messages	xboolean is_request;	// if TRUE, msg is a request, else response	int major_version;		// http major.minor version	int minor_version;	LinkedList headers;//NNS:	dlist headers;			// dlist<http_header_t *>	memptr entity;			// message body(entity)	// private fields	membuffer msg;		// entire raw message	char *urlbuf;	// storage for url string} http_message_t;typedef struct // http_parser_t{	http_message_t msg;	int http_error_code;	// read-only; in case of parse error, this							//  contains the HTTP error code (4XX or 5XX)    // read-only; this is set to true if a NOTIFY request has no content-length.    //  used to read valid sspd notify msg.    xboolean valid_ssdp_notify_hack;	// private data -- don't touch	parser_pos_t position;	int ent_position;	unsigned int content_length;	int chunk_size;	size_t entity_start_position;	scanner_t scanner;} http_parser_t;//--------------------------------------------------//////////////// functions ///////////////////////////--------------------------------------------------#ifdef __cplusplusextern "C" {#endif // __cplusplus/*************************************************************************	Function :	httpmsg_init**	Parameters :*		INOUT http_message_t* msg ;	HTTP Message Object**	Description :	Initialize and allocate memory for http message**	Return : void ;**	Note :************************************************************************/void httpmsg_init( INOUT http_message_t* msg );/*************************************************************************	Function :	httpmsg_destroy**	Parameters :*		INOUT http_message_t* msg ;	HTTP Message Object**	Description :	Free memory allocated for the http message*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -