libhttpd is a lib for supporting interaction using http protocols.
you can use it to quickly build an http server.
LibHttpd是一个开源轻量级嵌入式Web server,LibHttpd实现了下述功能:
- 实现了HTTP的子集;
- 使用表格技术自动处理Html Form数据;
- 产生的内容既可以是静态的网页,也可以是调用C函数动态产生的(callback);
LibHttpd提供API,利用这些API,用户可以很方便地将自己的Web内容加入到程序当中。
LibHTTPD相关函数介绍
-----------------------------------------------------------------------------------
httpdCreate ( ) 创建WEB服务器
httpd * httpdCreate ( host , port )
Example :
------------------------------------------------------------------------------------
httpdSetAccessLog( ) 设置访问日志文件
httpdSetAccessLog ( server, fp )
Example :
--------------------------------------------------------------------
httpdSetErrorLog( ) 设置错误日志文件
httpdSetErrorLog ( server, fp )
Example :
------------------------------------------------------------------------
httpdSetFileBase( ) 设置文件基本路径名
httpdSetErrorLog ( server, path )
Example :
------------------------------------------------------------------------
httpdAddCContent( ) 调用C函数产生输出内容
httpdAddCContent ( server, dir, name, indexFlag, preload, functPtr )
Example :
------------------------------------------------------------------------------------
httpdAddFileContent( ) 将一个外部文件加入到输出内容
httpdAddFileContent ( server, dir, name, indexFlag, preload, path )
Example :
-----------------------------------------------------------------------------------
httpdAddStaticContent( ) 将一个内部文本BUFFER加入到HTML输出内容
httpdAddStaticContent ( server, dir, name, indexFlag, preload, buf )
Example :
------------------------------------------------------------------------------------
httpdAddWildcardContent( ) 增加与通配符匹配的文件内容
httpdAddWildcardContent ( server, dir, preload, path )
Example :
-----------------------------------------------------------------------------------
httpdAddCWildcardContent
httpdAddCWildcardContent
Example :
---------------------------------------------------------------------------------
httpdGetConnection ( ) 接受一个HTTP连接请求
int httpdGetConnection ( server , timeout)
-----------------------------------------------------------------------
httpdReadRequest ( ) 读取并保存从客户端发送过来的请求和数据
int httpdReadRequest ( server )
-------------------------------------------------------------------------
httpdProcessRequest ( ) 对请求进行处理,并将请求内容发送到客户端浏览器
httpdProcessRequest ( server )
----------------------------------------------------------------------
httpdEndRequest ( ) 请求结束处理
httpdEndRequest ( server )
----------------------------------------------------------------------
httpdOutput ( ) 将文本BUFFER内容发送到客户端浏览器
httpdOutput ( server, buffer )
Example :
----------------------------------------------------------------------
httpdPrintf ( ) 按指定格式将内容输出到客户端浏览器
httpdPrintf ( server, format, arg, arg, … )
Example :
-------------------------------------------------------------------------
httpdSetContentType ( ) 设置除HTML文本以外的内容类型
httpdSetContentType( server, type )
Example :
------------------------------------------------------------------------
httpdSetResponse ( ) 设置返回给客户端浏览器的的响应代码
httpdSetResponse( server, responseInfo )
Example :
-------------------------------------------------------------------
httpdAddHeader ( ) 增加HTML头内容
httpdAddHeader( server, header )
Example :
---------------------------------------------------------------------------------
httpdSendHeaders( ) 发送HTML头
httpdSendHeaders( server)
Example :
---------------------------------------------------------------------------------
httpVar * httpdGetVariableByName ( ) 在符号表中查找变量
httpdGetVariableByName( server, varName )
Example :
------------------------------------------------------------------------------
httpVar * httpdGetVariableByPrefix
httpdGetVariableByPrefix
-------------------------------------------------------------------------
httpVar * httpdGetNextVariableByPr
httpdGetNextVariableByPr
Example :
------------------------------------------------------------------------
httpVar * httpdGetVariableByPrefix
httpdGetVariableByPrefix
Example :
------------------------------------------------------------------------------
httpdAddVariable( ) 在符号表中增加变量
httpdAddVariable( server, name, value )
Example :
---------------------------------------------------------------------------
httpdDumpVariables( ) Dump符号表内容
httpdDumpVariables( server )
-------------------------------------------------------------------------
httpdSet( ) 设置
httpdSet( server, name, value )
---------------------------------------------------------------------------
httpdAuthenticate( ) 使用用户名和口令进行身份认证
httpdAuthenticate( server, realm )
---------------------------------------------------------------------------
httpdForceAuthenticate( ) 强迫身份认证
httpdForceAuthenticate( server, realm )
------------------------------------------------------------------------------
httpdAddAcl( ) 在ACL表中增加访问控制项
httpdAddAcl( server, acl, cidrAddr, action )
-----------------------------------------------------------------------------
httpdSetDefaultAcl( ) 设置默认ACL
httpdSetDefaultAcl( server, acl )
--------------------------------------------------------------------
httpdCheckAcl( ) 进行ACL检查
httpdCheckAcl( server, acl )
-------------------------------------------------------------------
httpdUrlEncode( ) 进行URL解码
char * httpdUrlEncode( buf )
-------------------------------------------------------------------
httpdRequestMethod( ) 获取访问方式(HTTP_GET/HTTP_POST)
int httpdRequestMethod( server )
--------------------------------------------------------------------
httpdRequestMethodName( ) 获取访问方式名字
char *httpdRequestMethodName( server )
------------------------------------------------------------------
httpdRequestPath( ) 获取URL请求路径
char *httpdRequestPath( server )
----------------------------------------------------------------------
httpdRequestContentType( ) 获取当前请求内容类型
char *httpdRequestContentType( server )
-----------------------------------------------------------------------
httpdRequestContentLengt
int httpdRequestContentLengt
-----------------------------------------------------------------------