X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2FHTTPRequest.cxx;h=6b06785ad00bf57d79fb12e77b971a9475362138;hb=72bb9f4d5d6d861902a5779381e4ebe977db1df1;hp=3050cbf4e9594a693f0aeb18e797fdd6783fb04c;hpb=ef7a0dc5a3a225da7bf2d754e9f1bf2d234a11c4;p=simgear.git diff --git a/simgear/io/HTTPRequest.cxx b/simgear/io/HTTPRequest.cxx index 3050cbf4..6b06785a 100644 --- a/simgear/io/HTTPRequest.cxx +++ b/simgear/io/HTTPRequest.cxx @@ -32,6 +32,7 @@ extern const int DEFAULT_HTTP_PORT; //------------------------------------------------------------------------------ Request::Request(const std::string& url, const std::string method): + _client(0), _method(method), _url(url), _responseVersion(HTTP_VERSION_UNKNOWN), @@ -39,7 +40,8 @@ Request::Request(const std::string& url, const std::string method): _responseLength(0), _receivedBodyBytes(0), _ready_state(UNSENT), - _willClose(false) + _willClose(false), + _connectionCloseHeader(false) { } @@ -147,7 +149,10 @@ void Request::responseStart(const std::string& r) 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); @@ -361,23 +366,23 @@ void Request::setReadyState(ReadyState state) } //------------------------------------------------------------------------------ -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; } //------------------------------------------------------------------------------