本文整理汇总了C++中http::Request::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Request::get方法的具体用法?C++ Request::get怎么用?C++ Request::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http::Request
的用法示例。
在下文中一共展示了Request::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acceptRequest
void WebSocketFramer::acceptRequest(http::Request& request, http::Response& response)
{
if (util::icompare(request.get("Connection", ""), "upgrade") == 0 &&
util::icompare(request.get("Upgrade", ""), "websocket") == 0) {
std::string version = request.get("Sec-WebSocket-Version", "");
if (version.empty()) throw std::runtime_error("WebSocket error: Missing Sec-WebSocket-Version in handshake request"); //, ws::ErrorHandshakeNoVersion
if (version != ws::ProtocolVersion) throw std::runtime_error("WebSocket error: Unsupported WebSocket version requested: " + version); //, ws::ErrorHandshakeUnsupportedVersion
std::string key = util::trim(request.get("Sec-WebSocket-Key", ""));
if (key.empty()) throw std::runtime_error("WebSocket error: Missing Sec-WebSocket-Key in handshake request"); //, ws::ErrorHandshakeNoKey
response.setStatus(http::StatusCode::SwitchingProtocols);
response.set("Upgrade", "websocket");
response.set("Connection", "Upgrade");
response.set("Sec-WebSocket-Accept", computeAccept(key));
// Set headerState 2 since the handshake was accepted.
_headerState = 2;
}
else throw std::runtime_error("WebSocket error: No WebSocket handshake"); //, ws::ErrorNoHandshake
}
示例2: updateAuthInfo
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
}
}
示例3: hasProxyDigestCredentials
bool hasProxyDigestCredentials(const http::Request& request)
{
return request.has("Proxy-Authorization") &&
isDigestCredentials(request.get("Proxy-Authorization"));
}
示例4: hasBasicCredentials
bool hasBasicCredentials(const http::Request& request)
{
return request.has("Authorization") &&
isBasicCredentials(request.get("Authorization"));
}