GH #2549: Fix keepAlive in http client session: left-over _pRequestStream could mess up new request

This commit is contained in:
Günter Obiltschnig 2019-01-16 11:37:32 +01:00
parent 69fee5d296
commit be662f257a

View File

@ -165,7 +165,7 @@ void HTTPClientSession::setProxyUsername(const std::string& username)
{ {
_proxyConfig.username = username; _proxyConfig.username = username;
} }
void HTTPClientSession::setProxyPassword(const std::string& password) void HTTPClientSession::setProxyPassword(const std::string& password)
{ {
@ -193,8 +193,9 @@ void HTTPClientSession::setKeepAliveTimeout(const Poco::Timespan& timeout)
std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request) std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
{ {
clearException(); _pRequestStream = 0;
_pResponseStream = 0; _pResponseStream = 0;
clearException();
_responseReceived = false; _responseReceived = false;
bool keepAlive = getKeepAlive(); bool keepAlive = getKeepAlive();
@ -247,7 +248,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
{ {
_pRequestStream = new HTTPOutputStream(*this); _pRequestStream = new HTTPOutputStream(*this);
request.write(*_pRequestStream); request.write(*_pRequestStream);
} }
_lastRequest.update(); _lastRequest.update();
return *_pRequestStream; return *_pRequestStream;
} }
@ -301,7 +302,7 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
#endif #endif
else else
_pResponseStream = new HTTPInputStream(*this); _pResponseStream = new HTTPInputStream(*this);
return *_pResponseStream; return *_pResponseStream;
} }