xrtHttpServerConfigInit

XRT_API void xrtHttpServerConfigInit(xhttpserverconfig* pConfig);

;
返回:XRT_API void xrtHttpServerConfigInit(xhttpserverconfig* pConfig);

示例已编译验证

httpserverconfiginit obj;
xrtHttpServerConfigInit(&obj);

xrtHttpServerEventsInit

XRT_API void xrtHttpServerEventsInit(xhttpserverevents* pEvents);

;
返回:XRT_API void xrtHttpServerEventsInit(xhttpserverevents* pEvents);

示例已编译验证

httpservereventsinit obj;
xrtHttpServerEventsInit(&obj);

xrtHttpServerStart

创建并立即启动一个明文 HTTP/1 TCP Server。

xhttpserver* xrtHttpServerStart( xnetengine* pEngine, const xhttpserverconfig* pConfig, const xhttpserverevents* pEvents );
参数说明
xnetengine* pEngine网络引擎
const xhttpserverconfig* pConfig配置结构
const xhttpserverevents* pEvents事件回调表
返回:创建并立即启动一个明文 HTTP/1 TCP Server。

示例已编译验证

/* 创建并立即启动一个明文 HTTP/1 TCP Server。 */
result = xrtHttpServerStart(pEngine, pConfig, pEvents);

xrtHttpServerRef

增加 Server 引用并返回原指针。

xhttpserver* xrtHttpServerRef(xhttpserver* pServer);
参数说明
xhttpserver* pServer服务端对象
返回:增加 Server 引用并返回原指针。

示例已编译验证

/* 增加 Server 引用并返回原指针。 */
result = xrtHttpServerRef(pServer);

xrtHttpServerDestroy

释放 Server 引用;不会隐式停止仍在运行的 Server。

void xrtHttpServerDestroy(xhttpserver* pServer);
参数说明
xhttpserver* pServer服务端对象
返回:释放 Server 引用;不会隐式停止仍在运行的 Server。

示例已编译验证

xrtHttpServerDestroy(pServer);

xrtHttpServerDrain

停止接受新连接,关闭空闲连接并让活动请求发送最后一个响应。

bool xrtHttpServerDrain(xhttpserver* pServer);
参数说明
xhttpserver* pServer服务端对象
返回:停止接受新连接,关闭空闲连接并让活动请求发送最后一个响应。

示例已编译验证

/* 停止接受新连接,关闭空闲连接并让活动请求发送最后一个响应。 */
result = xrtHttpServerDrain(pServer);

xrtHttpServerAbort

停止接受并异常关闭全部 HTTP 连接。

bool xrtHttpServerAbort(xhttpserver* pServer);
参数说明
xhttpserver* pServer服务端对象
返回:停止接受并异常关闭全部 HTTP 连接。

示例已编译验证

/* 停止接受并异常关闭全部 HTTP 连接。 */
result = xrtHttpServerAbort(pServer);

xrtHttpServerState

返回 Server 当前生命周期状态。

xhttpserverstate xrtHttpServerState(const xhttpserver* pServer);
参数说明
const xhttpserver* pServer服务端对象
返回:返回 Server 当前生命周期状态。

示例已编译验证

/* 返回 Server 当前生命周期状态。 */
result = xrtHttpServerState(pServer);

xrtHttpServerSecure

返回 Server 是否使用 TLS 传输。

bool xrtHttpServerSecure(const xhttpserver* pServer);
参数说明
const xhttpserver* pServer服务端对象
返回:返回 Server 是否使用 TLS 传输。

示例已编译验证

/* 返回 Server 是否使用 TLS 传输。 */
result = xrtHttpServerSecure(pServer);

xrtHttpServerEndpointCount

返回 HTTP Server 的逻辑监听端点数量。

size_t xrtHttpServerEndpointCount( const xhttpserver* pServer );
参数说明
const xhttpserver* pServer服务端对象
返回:返回 HTTP Server 的逻辑监听端点数量。

示例已编译验证

/* 返回 HTTP Server 的逻辑监听端点数量。 */
result = xrtHttpServerEndpointCount(pServer);

xrtHttpServerLocal

复制指定逻辑端点的实际监听地址;输出可未对齐,但不得覆盖 Server。

bool xrtHttpServerLocal( const xhttpserver* pServer, size_t iEndpoint, xnetaddr* pAddress );
参数说明
const xhttpserver* pServer服务端对象
size_t iEndpointEndont 参数
xnetaddr* pAddress地址
返回:复制指定逻辑端点的实际监听地址;输出可未对齐,但不得覆盖 Server。

示例已编译验证

/* 复制指定逻辑端点的实际监听地址;输出可未对齐,但不得覆盖 Server。 */
result = xrtHttpServerLocal(pServer, iEndpoint, pAddress);

xrtHttpServerListenerCount

返回 HTTP Server 当前拥有的实际底层 Listener 数量。

size_t xrtHttpServerListenerCount( const xhttpserver* pServer );
参数说明
const xhttpserver* pServer服务端对象
返回:返回 HTTP Server 当前拥有的实际底层 Listener 数量。

示例已编译验证

/* 返回 HTTP Server 当前拥有的实际底层 Listener 数量。 */
result = xrtHttpServerListenerCount(pServer);

xrtHttpServerNetwork

增加并返回底层 TCP Server 引用,供特殊场景继续使用网络层能力。

xnetserver* xrtHttpServerNetwork(xhttpserver* pServer);
参数说明
xhttpserver* pServer服务端对象
返回:增加并返回底层 TCP Server 引用,供特殊场景继续使用网络层能力。

示例已编译验证

/* 增加并返回底层 TCP Server 引用,供特殊场景继续使用网络层能力。 */
result = xrtHttpServerNetwork(pServer);

xrtHttpServerError

返回导致网络 Server 终止的借用结构化错误。

const xerror* xrtHttpServerError( const xhttpserver* pServer );
参数说明
const xhttpserver* pServer服务端对象
返回:返回导致网络 Server 终止的借用结构化错误。

示例已编译验证

/* 返回导致网络 Server 终止的借用结构化错误。 */
result = xrtHttpServerError(pServer);

xrtHttpServerStats

复制 Server 并发统计;输出可未对齐,但不得覆盖 Server。

bool xrtHttpServerStats( const xhttpserver* pServer, xhttpserverstats* pStats );
参数说明
const xhttpserver* pServer服务端对象
xhttpserverstats* pStats出:统计快照
返回:复制 Server 并发统计;输出可未对齐,但不得覆盖 Server。

示例已编译验证

/* 复制 Server 并发统计;输出可未对齐,但不得覆盖 Server。 */
result = xrtHttpServerStats(pServer, pStats);

xrtHttpConnRef

增加 Connection 引用并返回原指针。

xhttpconn* xrtHttpConnRef(xhttpconn* pConnection);
参数说明
xhttpconn* pConnection连接对象
返回:增加 Connection 引用并返回原指针。

示例已编译验证

/* 增加 Connection 引用并返回原指针。 */
result = xrtHttpConnRef(pConnection);

xrtHttpConnDestroy

释放 Connection 引用;空指针视为空操作。

void xrtHttpConnDestroy(xhttpconn* pConnection);
参数说明
xhttpconn* pConnection连接对象
返回:释放 Connection 引用;空指针视为空操作。

示例已编译验证

xrtHttpConnDestroy(pConnection);

xrtHttpConnState

返回 Connection 当前协议阶段。

xhttpconnstate xrtHttpConnState( const xhttpconn* pConnection );
参数说明
const xhttpconn* pConnection连接对象
返回:返回 Connection 当前协议阶段。

示例已编译验证

/* 返回 Connection 当前协议阶段。 */
result = xrtHttpConnState(pConnection);

xrtHttpConnServer

返回借用的所属 Server。

xhttpserver* xrtHttpConnServer( const xhttpconn* pConnection );
参数说明
const xhttpconn* pConnection连接对象
返回:返回借用的所属 Server。

示例已编译验证

/* 返回借用的所属 Server。 */
result = xrtHttpConnServer(pConnection);

xrtHttpConnRequest

返回当前请求的借用指针;没有活动请求时为空。

const xhttpserverrequest* xrtHttpConnRequest( const xhttpconn* pConnection );
参数说明
const xhttpconn* pConnection连接对象
返回:返回当前请求的借用指针;没有活动请求时为空。

示例已编译验证

/* 返回当前请求的借用指针;没有活动请求时为空。 */
result = xrtHttpConnRequest(pConnection);

xrtHttpConnWorker

返回 Connection 所属的借用 Worker。

xnetworker* xrtHttpConnWorker( const xhttpconn* pConnection );
参数说明
const xhttpconn* pConnection连接对象
返回:返回 Connection 所属的借用 Worker。

示例已编译验证

/* 返回 Connection 所属的借用 Worker。 */
result = xrtHttpConnWorker(pConnection);

xrtHttpConnTcp

只在 Connection Worker 回调内返回底层借用 TCP Stream,包括 TLS 的传输。

xnetstream* xrtHttpConnTcp(xhttpconn* pConnection);
参数说明
xhttpconn* pConnection连接对象
返回:只在 Connection Worker 回调内返回底层借用 TCP Stream,包括 TLS 的传输。

示例已编译验证

/* 只在 Connection Worker 回调内返回底层借用 TCP Stream,包括 TLS 的传输。 */
result = xrtHttpConnTcp(pConnection);

xrtHttpConnSecure

返回 Connection 是否使用 TLS 传输。

bool xrtHttpConnSecure(const xhttpconn* pConnection);
参数说明
const xhttpconn* pConnection连接对象
返回:返回 Connection 是否使用 TLS 传输。

示例已编译验证

/* 返回 Connection 是否使用 TLS 传输。 */
result = xrtHttpConnSecure(pConnection);

xrtHttpConnEndpoint

返回接受当前 Connection 的逻辑 Server 端点索引。

size_t xrtHttpConnEndpoint(const xhttpconn* pConnection);
参数说明
const xhttpconn* pConnection连接对象
返回:返回接受当前 Connection 的逻辑 Server 端点索引。

示例已编译验证

/* 返回接受当前 Connection 的逻辑 Server 端点索引。 */
result = xrtHttpConnEndpoint(pConnection);

xrtHttpConnLocal

复制连接本地地址;输出可未对齐、成功才修改,且不得覆盖 Connection。

bool xrtHttpConnLocal( const xhttpconn* pConnection, xnetaddr* pAddress );
参数说明
const xhttpconn* pConnection连接对象
xnetaddr* pAddress地址
返回:复制连接本地地址;输出可未对齐、成功才修改,且不得覆盖 Connection。

示例已编译验证

/* 复制连接本地地址;输出可未对齐、成功才修改,且不得覆盖 Connection。 */
result = xrtHttpConnLocal(pConnection, pAddress);

xrtHttpConnRemote

复制连接远端地址;输出可未对齐、成功才修改,且不得覆盖 Connection。

bool xrtHttpConnRemote( const xhttpconn* pConnection, xnetaddr* pAddress );
参数说明
const xhttpconn* pConnection连接对象
xnetaddr* pAddress地址
返回:复制连接远端地址;输出可未对齐、成功才修改,且不得覆盖 Connection。

示例已编译验证

/* 复制连接远端地址;输出可未对齐、成功才修改,且不得覆盖 Connection。 */
result = xrtHttpConnRemote(pConnection, pAddress);

xrtHttpConnError

返回导致连接关闭或协议终止的借用结构化错误。

const xerror* xrtHttpConnError( const xhttpconn* pConnection );
参数说明
const xhttpconn* pConnection连接对象
返回:返回导致连接关闭或协议终止的借用结构化错误。

示例已编译验证

/* 返回导致连接关闭或协议终止的借用结构化错误。 */
result = xrtHttpConnError(pConnection);

xrtHttpConnStats

复制 Connection 协议和传输统计;输出可未对齐,但不得覆盖 Connection。

bool xrtHttpConnStats( const xhttpconn* pConnection, xhttpconnstats* pStats );
参数说明
const xhttpconn* pConnection连接对象
xhttpconnstats* pStats出:统计快照
返回:复制 Connection 协议和传输统计;输出可未对齐,但不得覆盖 Connection。

示例已编译验证

/* 复制 Connection 协议和传输统计;输出可未对齐,但不得覆盖 Connection。 */
result = xrtHttpConnStats(pConnection, pStats);

xrtHttpConnSetRequestBodyLimit

XRT_API bool xrtHttpConnSetRequestBodyLimit( xhttpconn* pConnection, uint64 iMaxBody );

;
返回:XRT_API bool xrtHttpConnSetRequestBodyLimit( xhttpconn* pConnection, uint64 iMaxBody );

示例已编译验证

/* XRT_API bool xrtHttpConnSetRequestBodyLimit( xhttpconn* pConnection, uint64 iMaxBody ); */
result = xrtHttpConnSetRequestBodyLimit();

xrtHttpConnPauseRequestBody

XRT_API bool xrtHttpConnPauseRequestBody( xhttpconn* pConnection );

;
返回:XRT_API bool xrtHttpConnPauseRequestBody( xhttpconn* pConnection );

示例已编译验证

/* XRT_API bool xrtHttpConnPauseRequestBody( xhttpconn* pConnection ); */
result = xrtHttpConnPauseRequestBody();

xrtHttpConnResumeRequestBody

XRT_API bool xrtHttpConnResumeRequestBody( xhttpconn* pConnection );

;
返回:XRT_API bool xrtHttpConnResumeRequestBody( xhttpconn* pConnection );

示例已编译验证

/* XRT_API bool xrtHttpConnResumeRequestBody( xhttpconn* pConnection ); */
result = xrtHttpConnResumeRequestBody();

xrtHttpConnRequestBodyPaused

返回请求正文是否被应用暂停的并发快照。

bool xrtHttpConnRequestBodyPaused( const xhttpconn* pConnection );
参数说明
const xhttpconn* pConnection连接对象
返回:返回请求正文是否被应用暂停的并发快照。

示例已编译验证

/* 返回请求正文是否被应用暂停的并发快照。 */
result = xrtHttpConnRequestBodyPaused(pConnection);

xrtHttpConnInform

XRT_API xnetresult xrtHttpConnInform( xhttpconn* pConnection, const xhttpreply* pReply );

;
返回:XRT_API xnetresult xrtHttpConnInform( xhttpconn* pConnection, const xhttpreply* pReply );

示例已编译验证

/* XRT_API xnetresult xrtHttpConnInform( xhttpconn* pConnection, const xhttpreply* pReply ); */
result = xrtHttpConnInform();

xrtHttpConnRespond

在 Connection Worker 上提交唯一最终 Reply。

xnetresult xrtHttpConnRespond( xhttpconn* pConnection, const xhttpreply* pReply );
参数说明
xhttpconn* pConnection连接对象
const xhttpreply* pReply回复队列
返回:在 Connection Worker 上提交唯一最终 Reply。

示例已编译验证

/* 在 Connection Worker 上提交唯一最终 Reply。 */
result = xrtHttpConnRespond(pConnection, pReply);

xrtHttpConnReply

一次调用复制常用固定正文并提交最终响应。

xnetresult xrtHttpConnReply( xhttpconn* pConnection, uint16 iStatus, xstrview ContentType, xbytesview Body );
参数说明
xhttpconn* pConnection连接对象
uint16 iStatus状态码
xstrview ContentType内容类型
xbytesview Body消息体内容
返回:一次调用复制常用固定正文并提交最终响应。

示例已编译验证

/* 一次调用复制常用固定正文并提交最终响应。 */
result = xrtHttpConnReply(pConnection, iStatus, ContentType, Body);

xrtHttpConnReplyBody

XRT_API xnetresult xrtHttpConnReplyBody( xhttpconn* pConnection, uint16 iStatus, xstrview ContentType, xhttpbody* pBody );

;
返回:XRT_API xnetresult xrtHttpConnReplyBody( xhttpconn* pConnection, uint16 iStatus, xstrview ContentType, xhttpbody* pBody );

示例已编译验证

/* XRT_API xnetresult xrtHttpConnReplyBody( xhttpconn* pConnection, uint16 iStatus, xstrview ContentType, xhttpbody* pBody ); */
result = xrtHttpConnReplyBody();

xrtHttpConnClose

从任意线程停止读取并在已经受理的响应字节排空后关闭。

bool xrtHttpConnClose(xhttpconn* pConnection);
参数说明
xhttpconn* pConnection连接对象
返回:从任意线程停止读取并在已经受理的响应字节排空后关闭。

示例已编译验证

/* 从任意线程停止读取并在已经受理的响应字节排空后关闭。 */
result = xrtHttpConnClose(pConnection);

xrtHttpConnAbort

从任意线程丢弃发送队列并异常关闭。

bool xrtHttpConnAbort(xhttpconn* pConnection);
参数说明
xhttpconn* pConnection连接对象
返回:从任意线程丢弃发送队列并异常关闭。

示例已编译验证

/* 从任意线程丢弃发送队列并异常关闭。 */
result = xrtHttpConnAbort(pConnection);