本文整理汇总了C++中HttpHeader::needCloseConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpHeader::needCloseConnection方法的具体用法?C++ HttpHeader::needCloseConnection怎么用?C++ HttpHeader::needCloseConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHeader
的用法示例。
在下文中一共展示了HttpHeader::needCloseConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertHttpCodeToUpdaterCode
//.........这里部分代码省略.........
useProxy,
serverAddress,
userAgent,
proxyAuthorizationHeader,
m_regettingPosition,
m_postData);
TRACE_MESSAGE2("Sending HTTP request\n%s", requestBuilder.toString().c_str());
if(requestBuffer.empty())
{
TRACE_MESSAGE("Failed to send empty HTTP request");
return CORE_DOWNLOAD_ERROR;
}
const CoreError sendRequestResult = m_socket.send(reinterpret_cast<const char *>(&requestBuffer[0]), requestBuffer.size());
if(sendRequestResult != CORE_NO_ERROR)
{
TRACE_MESSAGE2("Failed to send HTTP request, error %S", toString(sendRequestResult).toWideChar());
if((sendRequestResult == CORE_REMOTE_HOST_CLOSED_CONNECTION)
&& previousResponseReceived && authorizationTypeSwitched && !requestHasAlreadyBeenRepeated)
{
TRACE_MESSAGE("Repeating the same request (without authorization switch), because server was reachable, but unexpectedly closed connection");
requestHasAlreadyBeenRepeated = true;
continue;
}
return sendRequestResult;
}
HttpHeader httpHeader;
const CoreError receiveResponseAndDataResult = receiveResponseAndData(httpHeader);
const bool needCloseConnection = httpHeader.needCloseConnection(useProxy)
|| (receiveResponseAndDataResult != CORE_NO_ERROR);
if(needCloseConnection)
{
TRACE_MESSAGE2("Closing connection to HTTP server, get file result %S",
toString(receiveResponseAndDataResult).toWideChar());
closeSession();
}
if(receiveResponseAndDataResult != CORE_NO_ERROR)
{
TRACE_MESSAGE2("Failed to receive HTTP response, error %S",
toString(receiveResponseAndDataResult).toWideChar());
if((receiveResponseAndDataResult == CORE_REMOTE_HOST_CLOSED_CONNECTION)
&& previousResponseReceived && authorizationTypeSwitched && !requestHasAlreadyBeenRepeated)
{
TRACE_MESSAGE("Repeating the same request (without authorization switch), because server was reachable, but unexpectedly closed connection");
requestHasAlreadyBeenRepeated = true;
continue;
}
return receiveResponseAndDataResult;
}
previousResponseReceived = true;
requestHasAlreadyBeenRepeated = false;
m_authorizationDriver.authorized(
// authorization information is reset in case connection is to be closed
!needCloseConnection
// authorization success in case file received or successful redirect
&& (httpHeader.isFile()
|| httpHeader.redirectRequired()