本文整理汇总了C++中HttpConnection::DataOut方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpConnection::DataOut方法的具体用法?C++ HttpConnection::DataOut怎么用?C++ HttpConnection::DataOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpConnection
的用法示例。
在下文中一共展示了HttpConnection::DataOut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findHttpConnection
AP_MSG_HANDLER_METHOD(ServerModule, HttpServer_SendResponse)
{
HttpConnection* pConnection = findHttpConnection(pMsg->hConnection);
if (pConnection == 0) { throw ApException(LOG_CONTEXT, "findHttpConnection(" ApHandleFormat ") failed", ApHandlePrintf(pMsg->hConnection)); }
String sHeader;
if (!pMsg->sProtocol) {
pMsg->sProtocol = "HTTP/1.1";
}
if (pMsg->nStatus == 0) {
pMsg->nStatus = 200;
}
if (!pMsg->sMessage) {
if (pMsg->nStatus == 200) {
pMsg->sMessage = "OK";
} else {
pMsg->sMessage = "No Message";
}
}
sHeader.appendf("%s %d %s\r\n", _sz(pMsg->sProtocol), pMsg->nStatus, _sz(pMsg->sMessage));
{
for (Apollo::KeyValueElem* e = 0; (e = pMsg->kvHeader.nextElem(e)) != 0; ) {
sHeader.appendf("%s: %s\r\n", _sz(e->getKey()), _sz(e->getString()));
}
}
if (pMsg->sbBody.Length() > 0) {
if (pMsg->kvHeader.find("content-length", Apollo::KeyValueList::IgnoreCase)) {
} else {
sHeader.appendf("Content-length: %d\r\n", pMsg->sbBody.Length());
}
} else {
sHeader.appendf("Content-length: 0\r\n");
}
//sHeader += "Connection: close\r\n";
sHeader += "\r\n";
pConnection->DataOut((unsigned char*) sHeader.c_str(), sHeader.bytes());
if (pMsg->sbBody.Length() > 0) {
pConnection->DataOut(pMsg->sbBody.Data(), pMsg->sbBody.Length());
}
pMsg->apStatus = ApMessage::Ok;
}