improved WebSocket client error reporting

This commit is contained in:
Guenter Obiltschnig 2013-06-22 09:31:46 +02:00
parent a00b202f6c
commit 364536c5fd

View File

@ -1,7 +1,7 @@
//
// WebSocket.cpp
//
// $Id: //poco/1.4/Net/src/WebSocket.cpp#6 $
// $Id: //poco/1.4/Net/src/WebSocket.cpp#7 $
//
// Library: Net
// Package: WebSocket
@ -202,8 +202,15 @@ WebSocketImpl* WebSocket::connect(HTTPClientSession& cs, HTTPRequest& request, H
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);
}
else
{
throw WebSocketException("Cannot upgrade to WebSocket connection", response.getReason(), WS_ERR_NO_HANDSHAKE);
}
}
WebSocketImpl* WebSocket::completeHandshake(HTTPClientSession& cs, HTTPResponse& response, const std::string& key)