本文整理汇总了C++中http::Response::getStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ Response::getStatus方法的具体用法?C++ Response::getStatus怎么用?C++ Response::getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http::Response
的用法示例。
在下文中一共展示了Response::getStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doHttpPost
am_status_t BaseService::doHttpPost(const ServiceInfo& service,
const std::string& uriParameters,
const Http::CookieList& cookieList,
const BodyChunkList& bodyChunkList,
Http::Response& response,
std::size_t initialBufferLen,
const std::string &cert_nick_name,
bool doFormPost,
bool checkHTTPRetCode,
const ServerInfo **serverInfo) const
{
am_status_t status;
if(doFormPost) {
status = doRequest(service, postPrefixChunk, uriParameters,
cookieList, postFormSuffixChunk, bodyChunkList,
response, initialBufferLen, cert_nick_name,
serverInfo);
} else {
status = doRequest(service, postPrefixChunk, uriParameters,
cookieList, postSuffixChunk, bodyChunkList,
response, initialBufferLen, cert_nick_name,
serverInfo);
}
if (checkHTTPRetCode &&
(AM_SUCCESS == status && Http::OK != response.getStatus())) {
Http::Status httpStatus = response.getStatus();
if (Http::NOT_FOUND == httpStatus) {
status = AM_NOT_FOUND;
} else if (Http::FORBIDDEN == httpStatus) {
status = AM_ACCESS_DENIED;
} else {
Log::log(logModule, Log::LOG_WARNING,
"BaseService::doHttpPost() failed, HTTP error = %d",
httpStatus);
status = AM_HTTP_ERROR;
}
}
return status;
}
示例2: checkHandshakeResponse
bool WebSocketFramer::checkHandshakeResponse(http::Response& response)
{
assert(_mode == ws::ClientSide);
assert(_headerState == 1);
if (response.getStatus() == http::StatusCode::SwitchingProtocols)
{
// Complete handshake or throw
completeHandshake(response);
// Success
_headerState++;
assert(handshakeComplete());
return true;
}
else if (response.getStatus() == http::StatusCode::Unauthorized)
assert(0 && "authentication not implemented");
else
throw std::runtime_error("WebSocket error: Cannot upgrade to WebSocket connection: " + response.getReason()); //, ws::ErrorNoHandshake
// Need to resend request
return false;
}
示例3: doHttpPost
am_status_t BaseService::doHttpPost(const ServiceInfo& service,
const std::string& uriParameters,
const Http::CookieList& cookieList,
const BodyChunkList& bodyChunkList,
Http::Response& response,
bool doFormPost,
bool checkHTTPRetCode,
const ServerInfo **serverInfo) const {
am_status_t status;
if (doFormPost) {
status = doRequest(service, BodyChunk(std::string(HTTP_POST_PREFIX)), uriParameters,
cookieList, BodyChunk(std::string(HTTP_POST_FORM_SUFFIX)), bodyChunkList,
response, serverInfo);
} else {
status = doRequest(service, BodyChunk(std::string(HTTP_POST_PREFIX)), uriParameters,
cookieList, BodyChunk(std::string(HTTP_POST_SUFFIX)), bodyChunkList,
response, serverInfo);
}
if (checkHTTPRetCode &&
(AM_SUCCESS == status && Http::OK != response.getStatus())) {
Http::Status httpStatus = response.getStatus();
if (Http::NOT_FOUND == httpStatus) {
status = AM_NOT_FOUND;
} else if (Http::FORBIDDEN == httpStatus) {
status = AM_ACCESS_DENIED;
} else {
Log::log(logModule, Log::LOG_ERROR,
"BaseService::doHttpPost() failed, HTTP error = %d",
httpStatus);
status = AM_HTTP_ERROR;
}
}
return status;
}
示例4: getPublicAddress
IpAddress IpAddress::getPublicAddress(Time timeout)
{
// The trick here is more complicated, because the only way
// to get our public IP address is to get it from a distant computer.
// Here we get the web page from http://www.sfml-dev.org/ip-provider.php
// and parse the result to extract our IP address
// (not very hard: the web page contains only our IP address).
Http server("www.sfml-dev.org");
Http::Request request("/ip-provider.php", Http::Request::Get);
Http::Response page = server.sendRequest(request, timeout);
if (page.getStatus() == Http::Response::Ok)
return IpAddress(page.getBody());
// Something failed: return an invalid address
return IpAddress();
}