fixed GH #2570: DialogSocket: receiveStatusMessage() - line length limit applies to entire multi-line message

This commit is contained in:
Günter Obiltschnig 2019-06-22 14:42:59 +02:00
parent 03ced50f88
commit 479564069e
2 changed files with 16 additions and 9 deletions

View File

@ -31,7 +31,7 @@ DialogSocket::DialogSocket():
} }
DialogSocket::DialogSocket(const SocketAddress& address): DialogSocket::DialogSocket(const SocketAddress& address):
StreamSocket(address), StreamSocket(address),
_pBuffer(0), _pBuffer(0),
_pNext(0), _pNext(0),
@ -41,7 +41,7 @@ DialogSocket::DialogSocket(const SocketAddress& address):
} }
DialogSocket::DialogSocket(const Socket& socket): DialogSocket::DialogSocket(const Socket& socket):
StreamSocket(socket), StreamSocket(socket),
_pBuffer(0), _pBuffer(0),
_pNext(0), _pNext(0),
@ -161,7 +161,7 @@ int DialogSocket::receiveStatusMessage(std::string& message)
while (status <= 0) while (status <= 0)
{ {
message += '\n'; message += '\n';
status = receiveStatusLine(message, MAX_LINE_LENGTH); status = receiveStatusLine(message, message.length() + MAX_LINE_LENGTH);
} }
} }
return status; return status;

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;
} }
@ -259,11 +260,16 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
} }
std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response) void HTTPClientSession::flushRequest()
{ {
_pRequestStream = 0; _pRequestStream = 0;
if (networkException()) networkException()->rethrow(); if (networkException()) networkException()->rethrow();
}
std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
{
flushRequest();
if (!_responseReceived) if (!_responseReceived)
{ {
do do
@ -301,7 +307,7 @@ std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response)
#endif #endif
else else
_pResponseStream = new HTTPInputStream(*this); _pResponseStream = new HTTPInputStream(*this);
return *_pResponseStream; return *_pResponseStream;
} }
@ -354,13 +360,14 @@ int HTTPClientSession::write(const char* buffer, std::streamsize length)
_reconnect = false; _reconnect = false;
return rc; return rc;
} }
catch (NetException&) catch (IOException&)
{ {
if (_reconnect) if (_reconnect)
{ {
close(); close();
reconnect(); reconnect();
int rc = HTTPSession::write(buffer, length); int rc = HTTPSession::write(buffer, length);
clearException();
_reconnect = false; _reconnect = false;
return rc; return rc;
} }