- 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:
Guenter Obiltschnig
2013-06-12 20:46:37 +02:00
parent 872744fd92
commit 9372096447
2 changed files with 9 additions and 105 deletions

View File

@@ -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)