only auto-authorize if non-empty HTTPCredentials are provided

This commit is contained in:
Günter Obiltschnig 2019-06-04 18:37:48 +02:00
parent 96a7263219
commit 5e678b925b

View File

@ -183,6 +183,8 @@ WebSocketImpl* WebSocket::connect(HTTPClientSession& cs, HTTPRequest& request, H
return completeHandshake(cs, response, key);
}
else if (response.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED)
{
if (!credentials.empty())
{
Poco::NullOutputStream null;
Poco::StreamCopier::copyStream(istr, null);
@ -203,6 +205,8 @@ WebSocketImpl* WebSocket::connect(HTTPClientSession& cs, HTTPRequest& request, H
throw WebSocketException("Not authorized", WS_ERR_UNAUTHORIZED);
}
}
else throw WebSocketException("Not authorized", WS_ERR_UNAUTHORIZED);
}
if (response.getStatus() == HTTPResponse::HTTP_OK)
{
throw WebSocketException("The server does not understand the WebSocket protocol", WS_ERR_NO_HANDSHAKE);