//------------------------------------------------------------------------------
Request::Request(const std::string& url, const std::string method):
+ _client(0),
_method(method),
_url(url),
_responseVersion(HTTP_VERSION_UNKNOWN),
_responseLength(0),
_receivedBodyBytes(0),
_ready_state(UNSENT),
- _willClose(false)
+ _willClose(false),
+ _connectionCloseHeader(false)
{
}
void Request::responseHeader(const std::string& key, const std::string& value)
{
if( key == "connection" ) {
- _willClose = (value.find("close") != std::string::npos);
+ _connectionCloseHeader = (value.find("close") != std::string::npos);
+ // track willClose seperately because other conditions (abort, for
+ // example) can also set it
+ _willClose = _connectionCloseHeader;
} else if (key == "content-length") {
int sz = strutils::to_int(value);
setResponseLength(sz);
//------------------------------------------------------------------------------
void Request::setFailure(int code, const std::string& reason)
{
+ SG_LOG(SG_IO, SG_WARN, "HTTP request: set failure:" << code << " reason " << reason);
_responseStatus = code;
_responseReason = reason;
}
//------------------------------------------------------------------------------
-void Request::abort()
+bool Request::closeAfterComplete() const
{
- abort("Request aborted.");
+ // for non HTTP/1.1 connections, assume server closes
+ return _willClose || (_responseVersion != HTTP_1_1);
}
-//----------------------------------------------------------------------------
-void Request::abort(const std::string& reason)
+//------------------------------------------------------------------------------
+
+void Request::setCloseAfterComplete()
{
- setFailure(-1, reason);
- _willClose = true;
+ _willClose = true;
}
//------------------------------------------------------------------------------
-bool Request::closeAfterComplete() const
+bool Request::serverSupportsPipelining() const
{
- // for non HTTP/1.1 connections, assume server closes
- return _willClose || (_responseVersion != HTTP_1_1);
+ return (_responseVersion == HTTP_1_1) && !_connectionCloseHeader;
}
//------------------------------------------------------------------------------