Exemple #1
0
void WebSocketFramer::createHandshakeRequest(http::Request& request)
{
	assert(_mode == ws::ClientSide);
	assert(_headerState == 0);

	// Send the handshake request
	_key = createKey();
	request.setChunkedTransferEncoding(false);
	request.set("Connection", "Upgrade");
	request.set("Upgrade", "websocket");
	request.set("Sec-WebSocket-Version", ws::ProtocolVersion);
	assert(request.has("Sec-WebSocket-Version"));
	request.set("Sec-WebSocket-Key", _key);
	assert(request.has("Sec-WebSocket-Key"));
	//TraceLS(this) << "Sec-WebSocket-Version: " << request.get("Sec-WebSocket-Version") << endl;
	//TraceLS(this) << "Sec-WebSocket-Key: " << request.get("Sec-WebSocket-Key") << endl;
	_headerState++;
}
Exemple #2
0
void Authenticator::updateAuthInfo(http::Request& request)
{
    if (request.has("Authorization")) {
        const std::string& authorization = request.get("Authorization");

        if (isBasicCredentials(authorization)) {
            BasicAuthenticator(_username, _password).authenticate(request);
        }
        // else if (isDigestCredentials(authorization))
        //    ; // TODO
    }
}
Exemple #3
0
bool hasProxyDigestCredentials(const http::Request& request)
{
    return request.has("Proxy-Authorization") &&
           isDigestCredentials(request.get("Proxy-Authorization"));
}
Exemple #4
0
bool hasBasicCredentials(const http::Request& request)
{
    return request.has("Authorization") &&
           isBasicCredentials(request.get("Authorization"));
}