xrtHttpServerConfigInit
XRT_API void xrtHttpServerConfigInit(xhttpserverconfig* pConfig);
示例已编译验证
httpserverconfiginit obj; xrtHttpServerConfigInit(&obj);
xrtHttpServerEventsInit
XRT_API void xrtHttpServerEventsInit(xhttpserverevents* pEvents);
示例已编译验证
httpservereventsinit obj; xrtHttpServerEventsInit(&obj);
xrtHttpServerStart
创建并立即启动一个明文 HTTP/1 TCP Server。
| 参数 | 说明 |
|---|---|
| xnetengine* pEngine | 网络引擎 |
| const xhttpserverconfig* pConfig | 配置结构 |
| const xhttpserverevents* pEvents | 事件回调表 |
示例已编译验证
/* 创建并立即启动一个明文 HTTP/1 TCP Server。 */ result = xrtHttpServerStart(pEngine, pConfig, pEvents);
xrtHttpServerRef
增加 Server 引用并返回原指针。
| 参数 | 说明 |
|---|---|
| xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 增加 Server 引用并返回原指针。 */ result = xrtHttpServerRef(pServer);
xrtHttpServerDestroy
释放 Server 引用;不会隐式停止仍在运行的 Server。
| 参数 | 说明 |
|---|---|
| xhttpserver* pServer | 服务端对象 |
示例已编译验证
xrtHttpServerDestroy(pServer);
xrtHttpServerDrain
停止接受新连接,关闭空闲连接并让活动请求发送最后一个响应。
| 参数 | 说明 |
|---|---|
| xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 停止接受新连接,关闭空闲连接并让活动请求发送最后一个响应。 */ result = xrtHttpServerDrain(pServer);
xrtHttpServerAbort
停止接受并异常关闭全部 HTTP 连接。
| 参数 | 说明 |
|---|---|
| xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 停止接受并异常关闭全部 HTTP 连接。 */ result = xrtHttpServerAbort(pServer);
xrtHttpServerState
返回 Server 当前生命周期状态。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 返回 Server 当前生命周期状态。 */ result = xrtHttpServerState(pServer);
xrtHttpServerSecure
返回 Server 是否使用 TLS 传输。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 返回 Server 是否使用 TLS 传输。 */ result = xrtHttpServerSecure(pServer);
xrtHttpServerEndpointCount
返回 HTTP Server 的逻辑监听端点数量。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 返回 HTTP Server 的逻辑监听端点数量。 */ result = xrtHttpServerEndpointCount(pServer);
xrtHttpServerLocal
复制指定逻辑端点的实际监听地址;输出可未对齐,但不得覆盖 Server。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
| size_t iEndpoint | Endont 参数 |
| xnetaddr* pAddress | 地址 |
示例已编译验证
/* 复制指定逻辑端点的实际监听地址;输出可未对齐,但不得覆盖 Server。 */ result = xrtHttpServerLocal(pServer, iEndpoint, pAddress);
xrtHttpServerListenerCount
返回 HTTP Server 当前拥有的实际底层 Listener 数量。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 返回 HTTP Server 当前拥有的实际底层 Listener 数量。 */ result = xrtHttpServerListenerCount(pServer);
xrtHttpServerNetwork
增加并返回底层 TCP Server 引用,供特殊场景继续使用网络层能力。
| 参数 | 说明 |
|---|---|
| xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 增加并返回底层 TCP Server 引用,供特殊场景继续使用网络层能力。 */ result = xrtHttpServerNetwork(pServer);
xrtHttpServerError
返回导致网络 Server 终止的借用结构化错误。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
示例已编译验证
/* 返回导致网络 Server 终止的借用结构化错误。 */ result = xrtHttpServerError(pServer);
xrtHttpServerStats
复制 Server 并发统计;输出可未对齐,但不得覆盖 Server。
| 参数 | 说明 |
|---|---|
| const xhttpserver* pServer | 服务端对象 |
| xhttpserverstats* pStats | 出:统计快照 |
示例已编译验证
/* 复制 Server 并发统计;输出可未对齐,但不得覆盖 Server。 */ result = xrtHttpServerStats(pServer, pStats);
xrtHttpConnRef
增加 Connection 引用并返回原指针。
| 参数 | 说明 |
|---|---|
| xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 增加 Connection 引用并返回原指针。 */ result = xrtHttpConnRef(pConnection);
xrtHttpConnDestroy
释放 Connection 引用;空指针视为空操作。
| 参数 | 说明 |
|---|---|
| xhttpconn* pConnection | 连接对象 |
示例已编译验证
xrtHttpConnDestroy(pConnection);
xrtHttpConnState
返回 Connection 当前协议阶段。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回 Connection 当前协议阶段。 */ result = xrtHttpConnState(pConnection);
xrtHttpConnServer
返回借用的所属 Server。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回借用的所属 Server。 */ result = xrtHttpConnServer(pConnection);
xrtHttpConnRequest
返回当前请求的借用指针;没有活动请求时为空。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回当前请求的借用指针;没有活动请求时为空。 */ result = xrtHttpConnRequest(pConnection);
xrtHttpConnWorker
返回 Connection 所属的借用 Worker。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回 Connection 所属的借用 Worker。 */ result = xrtHttpConnWorker(pConnection);
xrtHttpConnTcp
只在 Connection Worker 回调内返回底层借用 TCP Stream,包括 TLS 的传输。
| 参数 | 说明 |
|---|---|
| xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 只在 Connection Worker 回调内返回底层借用 TCP Stream,包括 TLS 的传输。 */ result = xrtHttpConnTcp(pConnection);
xrtHttpConnSecure
返回 Connection 是否使用 TLS 传输。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回 Connection 是否使用 TLS 传输。 */ result = xrtHttpConnSecure(pConnection);
xrtHttpConnEndpoint
返回接受当前 Connection 的逻辑 Server 端点索引。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回接受当前 Connection 的逻辑 Server 端点索引。 */ result = xrtHttpConnEndpoint(pConnection);
xrtHttpConnLocal
复制连接本地地址;输出可未对齐、成功才修改,且不得覆盖 Connection。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
| xnetaddr* pAddress | 地址 |
示例已编译验证
/* 复制连接本地地址;输出可未对齐、成功才修改,且不得覆盖 Connection。 */ result = xrtHttpConnLocal(pConnection, pAddress);
xrtHttpConnRemote
复制连接远端地址;输出可未对齐、成功才修改,且不得覆盖 Connection。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
| xnetaddr* pAddress | 地址 |
示例已编译验证
/* 复制连接远端地址;输出可未对齐、成功才修改,且不得覆盖 Connection。 */ result = xrtHttpConnRemote(pConnection, pAddress);
xrtHttpConnError
返回导致连接关闭或协议终止的借用结构化错误。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 返回导致连接关闭或协议终止的借用结构化错误。 */ result = xrtHttpConnError(pConnection);
xrtHttpConnStats
复制 Connection 协议和传输统计;输出可未对齐,但不得覆盖 Connection。
| 参数 | 说明 |
|---|---|
| const xhttpconn* pConnection | 连接对象 |
| xhttpconnstats* pStats | 出:统计快照 |
示例已编译验证
/* 复制 Connection 协议和传输统计;输出可未对齐,但不得覆盖 Connection。 */ result = xrtHttpConnStats(pConnection, pStats);
xrtHttpConnSetRequestBodyLimit
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 ); */ result = xrtHttpConnPauseRequestBody();
xrtHttpConnResumeRequestBody
XRT_API bool xrtHttpConnResumeRequestBody( xhttpconn* pConnection );
示例已编译验证
/* XRT_API bool xrtHttpConnResumeRequestBody( xhttpconn* pConnection ); */ result = xrtHttpConnResumeRequestBody();
xrtHttpConnRequestBodyPaused
返回请求正文是否被应用暂停的并发快照。
| 参数 | 说明 |
|---|---|
| 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 ); */ result = xrtHttpConnInform();
xrtHttpConnRespond
在 Connection Worker 上提交唯一最终 Reply。
| 参数 | 说明 |
|---|---|
| xhttpconn* pConnection | 连接对象 |
| const xhttpreply* pReply | 回复队列 |
示例已编译验证
/* 在 Connection Worker 上提交唯一最终 Reply。 */ result = xrtHttpConnRespond(pConnection, pReply);
xrtHttpConnReply
一次调用复制常用固定正文并提交最终响应。
| 参数 | 说明 |
|---|---|
| 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 ); */ result = xrtHttpConnReplyBody();
xrtHttpConnClose
从任意线程停止读取并在已经受理的响应字节排空后关闭。
| 参数 | 说明 |
|---|---|
| xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 从任意线程停止读取并在已经受理的响应字节排空后关闭。 */ result = xrtHttpConnClose(pConnection);
xrtHttpConnAbort
从任意线程丢弃发送队列并异常关闭。
| 参数 | 说明 |
|---|---|
| xhttpconn* pConnection | 连接对象 |
示例已编译验证
/* 从任意线程丢弃发送队列并异常关闭。 */ result = xrtHttpConnAbort(pConnection);