mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 00:07:59 +02:00
- fixed a potential memory leak in Poco::Net::HTTPClientSession if it is misused
(e.g., sendRequest() is sent two times in a row without an intermediate call to receiveResponse(), or by calling receiveResponse() two times in a row without an intermediate call to sendRequest()) - GH #217 - removed a few unnecessary protected accessor methods from Poco::Net::HTTPClientSession that would provide inappropriate access to internal state
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPClientSession.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Net/src/HTTPClientSession.cpp#8 $
|
||||
// $Id: //poco/1.4/Net/src/HTTPClientSession.cpp#10 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTPClient
|
||||
@@ -63,9 +63,7 @@ HTTPClientSession::HTTPClientSession():
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false),
|
||||
_pRequestStream(0),
|
||||
_pResponseStream(0)
|
||||
_expectResponseBody(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -77,9 +75,7 @@ HTTPClientSession::HTTPClientSession(const StreamSocket& socket):
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false),
|
||||
_pRequestStream(0),
|
||||
_pResponseStream(0)
|
||||
_expectResponseBody(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -91,9 +87,7 @@ HTTPClientSession::HTTPClientSession(const SocketAddress& address):
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false),
|
||||
_pRequestStream(0),
|
||||
_pResponseStream(0)
|
||||
_expectResponseBody(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -105,17 +99,13 @@ HTTPClientSession::HTTPClientSession(const std::string& host, Poco::UInt16 port)
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
_expectResponseBody(false),
|
||||
_pRequestStream(0),
|
||||
_pResponseStream(0)
|
||||
_expectResponseBody(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HTTPClientSession::~HTTPClientSession()
|
||||
{
|
||||
delete _pRequestStream;
|
||||
delete _pResponseStream;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +183,6 @@ void HTTPClientSession::setKeepAliveTimeout(const Poco::Timespan& timeout)
|
||||
|
||||
std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
||||
{
|
||||
delete _pResponseStream;
|
||||
_pResponseStream = 0;
|
||||
|
||||
bool keepAlive = getKeepAlive();
|
||||
@@ -259,7 +248,6 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
||||
|
||||
std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
|
||||
{
|
||||
delete _pRequestStream;
|
||||
_pRequestStream = 0;
|
||||
|
||||
do
|
||||
@@ -365,34 +353,6 @@ std::string HTTPClientSession::proxyRequestPrefix() const
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::deleteResponseStream()
|
||||
{
|
||||
delete _pResponseStream;
|
||||
_pResponseStream = 0;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::deleteRequestStream()
|
||||
{
|
||||
delete _pRequestStream;
|
||||
_pRequestStream = 0;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::setResponseStream(std::istream* pRespStream)
|
||||
{
|
||||
poco_assert (!_pResponseStream);
|
||||
_pResponseStream = pRespStream;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::setRequestStream(std::ostream* pRequestStream)
|
||||
{
|
||||
poco_assert (!_pRequestStream);
|
||||
_pRequestStream = pRequestStream;
|
||||
}
|
||||
|
||||
|
||||
bool HTTPClientSession::mustReconnect() const
|
||||
{
|
||||
if (!_mustReconnect)
|
||||
|
Reference in New Issue
Block a user