Пример #1
0
void WebSocketFramer::completeHandshake(http::Response& response)
{
	std::string connection = response.get("Connection", "");
	if (util::icompare(connection, "Upgrade") != 0) 
		throw std::runtime_error("WebSocket error: No Connection: Upgrade header in handshake response"); //, ws::ErrorNoHandshake
	std::string upgrade = response.get("Upgrade", "");
	if (util::icompare(upgrade, "websocket") != 0)
		throw std::runtime_error("WebSocket error: No Upgrade: websocket header in handshake response"); //, ws::ErrorNoHandshake
	std::string accept = response.get("Sec-WebSocket-Accept", "");
	if (accept != computeAccept(_key))
		throw std::runtime_error("WebSocket error: Invalid or missing Sec-WebSocket-Accept header in handshake response"); //, ws::ErrorNoHandshake
}