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

📄 httpcore.h

📁 mini http server,可以集成嵌入到程序中,实现简单的web功能
💻 H
📖 第 1 页 / 共 2 页
字号:
/*____________________________________________________________________________*\
 *

 Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.

 These sources, libraries and applications are
 FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
 as long as the following conditions are adhered to.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:

 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer. 

 2. 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.

 3. The name of the author may not be used to endorse or promote products
    derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 THE AUTHORS OR ITS 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.

 *____________________________________________________________________________*|
 *
 * $Source: /cvsroot/pi3web/Pi3Web_200/Source/Pi3API/HTTPCore.h,v $
 * $Date: 2003/05/13 18:42:09 $
 *
 Description:
\*____________________________________________________________________________*/
/* $SourceTop:$ */

#ifndef HTTPCORE_H_
#define HTTPCORE_H_

#include "Pi3API.h"

/*____________________________________________________________________________*\
 Description: Flags
\*____________________________________________________________________________*/
#define RH_CLIENTREQUEST	(1)
#define RH_RESPONSE			(2)

/* --- debug levels for HTTPCore_logDebug() --- */
#define DBG_LOW				(100)
#define DBG_MED				(50)
#define DBG_HIGH			(1)

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_initServer

 Synopsis:
	int HTTPCore_initServer( PIObject *pObject )

 Description:
	This function initiates the core HTTP server library and performs:
	<ul>
		<li>make sure fast keys are setup
		<li>read the server root and make it absolute
		<li>read server stamp
		<li>open error log and log initial message
		<li>open debug log and log initial message
		<li>load the debug expressions
		<li>create MIME database and read in MIME file
		<li>read the DefaultMIMEType
		<li>read MIME types from configuration
		<li>load top level handlers
	</ul>

 Notes:
	This function is called by the request dispatcher object internally.
	DefaultMIMEType is set to application/octet-stream if not set in
	configuration.

 Return Values:
	PIAPI_COMPLETED on success or PIAPI_ERROR otherwise

 Errors:
	PIAPI_ERROR

 See Also:
	HTTPCore_cleanupServer
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_initServer( PIObject *pObject );

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_initClient

 Synopsis:
	int HTTPCore_initClient()

 Description:
	This function initiates the core HTTP client library and performs:
	<ul>
		<li>make sure fast keys are setup
		<li>read client stamp
	</ul>

 Notes:
 Return Values:
	PIAPI_COMPLETED on success or PIAPI_ERROR otherwise

 Errors:
	PIAPI_ERROR

 See Also:
	HTTPCore_cleanupClient
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_initClient();

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_cleanupServer

 Synopsis:
	int HTTPCore_cleanupServer()

 Description:
	This function closes the core HTTP server library.

 Notes:
	This function is called by the request dispatcher object internally.

 Return Values:
	PIAPI_COMPLETED

 Errors:
 See Also:
	HTTPCore_initServer
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_cleanupServer();

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_cleanupClient

 Synopsis:
	int HTTPCore_cleanupClient()

 Description:
	This function closes the core HTTP client library.

 Notes:
 Return Values:
	PIAPI_COMPLETED

 Errors:
 See Also:
	HTTPCore_initClient
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_cleanupClient();

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_readHeaders

 Synopsis:
	int HTTPCore_readHeaders( PIIOBuffer *pB, PIDB *pDB, int iFlags )

 Description:
	This function reads in the HTTP request line and the HTTP request headers.
	The behaviour depends on the value of parameter iFlags:
	<TABLE>
		<TR><TD>RH_CLIENTREQUEST<TD>The server parses a new client-side request
		<TR><TD>RH_RESPONSE<TD>A client parses the response received by the server
	</TABLE>
	Consistency checks will be performed, the request or response line will be parsed
	and all header values will be written into the connection database given as pDB.

 Notes:
	This function is called by the server ReadRequestHeaders object internally.

 Return Values:
	Returns INT_CONTINUE on success, otherwise HTTPCore_readHeaders() returns
	an HTTP status code representing an error.


 Errors:
	<TABLE>
		<TR><TD>ST_BADREQUEST<TD>Non compliant or empty HTTP request line or headers
		<TR><TD>ST_REQUESTURITOOLONG<TD>Too long request line
		<TR><TD>ST_INTERNALERROR<TD>Unspecified internal error when reading request line
	</TABLE>
 See Also:
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_readHeaders( PIIOBuffer *pB, PIDB *pDB, int iFlags );

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_sendGeneralHeaders

 Synopsis:
	int HTTPCore_sendGeneralHeaders( PIHTTP *pPIHTTP )	

 Description:
	This function sends a HTTP response line and the general HTTP headers
	(Server, Date, Connection, Transfer-Encoding) in accordance with the
	used HTTP protocol version to the client.

 Notes:
	This function doesn't do anything for subrequests. If the HTTP status is 0
	then it's silently changed to 200 OK

 Return Values:
	PIAPI_COMPLETED on success or PIAPI_ERROR otherwise

 Errors:
	PIAPI_ERROR

 See Also:
	HTTPCore_sendEntityHeaders
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_sendGeneralHeaders( PIHTTP *pPIHTTP );	

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_sendEntityHeaders

 Synopsis:
	int HTTPCore_sendEntityHeaders( PIHTTP *pPIHTTP, PIDB *pR )

 Description:
	This function sends all entity specific RFC822 headers to the client.

 Notes:
	This function doesn't do anything for subrequests.

 Return Values:
	PIAPI_COMPLETED on success or PIAPI_ERROR otherwise

 Errors:
	PIAPI_ERROR

 See Also:
	HTTPCore_sendGeneralHeaders
\*____________________________________________________________________________*/
PUBLIC_PIAPI int HTTPCore_sendEntityHeaders( PIHTTP *pPIHTTP, PIDB *pR );

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_getCachedFile

 Synopsis:
	PIFInfo *HTTPCore_getCachedFile( const char *pPath )

 Description:
	Create an instance of a PIFInfo object from the given pPath to be used
	for reading the associated file.

 Notes:
 Return Values:
	A valid PIFInfo object or NULL on error.

 Errors:
 See Also:
	HTTPUtil_sendFile
	HTTPCore_releaseCachedFile
\*____________________________________________________________________________*/
PUBLIC_PIAPI PIFInfo *HTTPCore_getCachedFile( const char *pPath );

/*____________________________________________________________________________*\
 *
 Name:
	HTTPCore_getServerStamp

 Synopsis:
	const char *HTTPCore_getServerStamp()

 Description:
	This function retrieves the configured server name stamp.

 Notes:
 Return Values:
	The configured server name stamp, maybe empty string if nothing configured.

⌨️ 快捷键说明

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