当前位置: 首页>>代码示例>>C++>>正文


C++ Request::get方法代码示例

本文整理汇总了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
}
开发者ID:AsamQi,项目名称:libsourcey,代码行数:20,代码来源:websocket.cpp

示例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
    }
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例3: hasProxyDigestCredentials

bool hasProxyDigestCredentials(const http::Request& request)
{
    return request.has("Proxy-Authorization") &&
           isDigestCredentials(request.get("Proxy-Authorization"));
}
开发者ID:,项目名称:,代码行数:5,代码来源:

示例4: hasBasicCredentials

bool hasBasicCredentials(const http::Request& request)
{
    return request.has("Authorization") &&
           isBasicCredentials(request.get("Authorization"));
}
开发者ID:,项目名称:,代码行数:5,代码来源:


注:本文中的http::Request::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。