本文整理汇总了C++中HttpResponse::GetStatusCode方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpResponse::GetStatusCode方法的具体用法?C++ HttpResponse::GetStatusCode怎么用?C++ HttpResponse::GetStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::GetStatusCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: key
void
Network::OnTransactionCompleted (HttpSession &httpSession, HttpTransaction &httpTransaction) {
HttpResponse* pHttpResponse = httpTransaction.GetResponse();
NetHttpStatusCode statusCode = pHttpResponse->GetStatusCode();
int status = 1; // Default is DATA NETWORK
// FIXME: Bada has no standard/apparent way of knowing the current network type
// We have to get the network type from the system info
// ...and if Wifi is enabled we override the setting to Wifi
String key(L"NetworkType");
String networkType;
result r = SystemInfo::GetValue(key, networkType);
if(r == E_SUCCESS && networkType != L"NoService" && networkType != L"Emergency") {
AppLogDebug("Data Enabled, Network Type %S, Status Code: %d", networkType.GetPointer(), statusCode);
status = 1;
}
Wifi::WifiManager manager;
if(manager.IsActivated() && manager.IsConnected()) {
AppLogDebug("Wifi Enabled");
status = 2;
}
String res;
res.Format(256, L"navigator.network.updateReachability({code:%d,http_code:%d});", status, statusCode);
AppLogDebug("%S", res.GetPointer());
pWeb->EvaluateJavascriptN(res);
res.Format(128, L"Cordova.callbacks['%S'].success({code:%d,http_code:%d});", callbackId.GetPointer(), status, statusCode);
AppLogDebug("%S", res.GetPointer());
pWeb->EvaluateJavascriptN(res);
}
示例2: ngx_http_cxxmvc_handler
//.........这里部分代码省略.........
req.SetUrl(routingUrl);
req.SetIp(IP);
//req.SetHost(StringRef(host, strlen(host)));
req.SetUserAgent(userAgent);
req.SetUserCookie(StringRef(userCookie.c_str(), userCookie.length()));
req.SetAcceptLanguage(StringRef(lang.c_str(), lang.length()));
req.ParseCookie();
DE.ResponseRequest(req, res);
ngx_str_t k = ngx_string("X-Powered-By");
ngx_str_t v = ngx_string("cxxmvc/0.1");;
ngx_http_add_header(r, &v, &k);
if (res.GetResponseType() == kResponseTypeRedirect)
{
ngx_str_t k = ngx_string("location");
ngx_str_t v = {res.GetContent().length(), (u_char *)res.GetContent().c_str()};
ngx_http_add_header(r, &v, &k);
}
HeaderList headers = res.GetHeaders();
if (headers.size() > 0)
{
HeaderList::iterator iter;
HeaderList::iterator end = headers.end();
for (iter = headers.begin(); iter != end; ++iter)
{
ngx_str_t k;
ngx_str_t v;
k.data = (u_char *)ngx_pcalloc(r->pool, iter->first.length()+1);
k.len = iter->first.length();
strcpy((char *)k.data, (const char *)iter->first.c_str());
v.data = (u_char *)ngx_pcalloc(r->pool, iter->second.length()+1);
v.len = iter->second.length();
strcpy((char *)v.data, (const char *)iter->second.c_str());
// std::cout << "key : "<< k.data << std::endl;
// std::cout << "value : " << v.data << std::endl;
ngx_http_add_header(r, &v, &k);
}
}
CookieList cookies = res.GetCookies();
if (cookies.size() > 0)
{
CookieList::iterator iter;
CookieList::iterator end = cookies.end();
for (iter = cookies.begin(); iter != end; ++iter)
{
ngx_str_t v;
v.data = (u_char *)ngx_pcalloc(r->pool, iter->length()+1);
v.len = iter->length();
strcpy((char *)v.data, (const char *)iter->c_str());
ngx_http_add_cookie(r, v);
}
}
r->headers_out.status = res.GetStatusCode();
r->headers_out.content_type.len = res.GetContentType().length();
r->headers_out.content_type.data = (u_char *)res.GetContentType().c_str();
if (res.GetDetaRef().length() > 0)
r->headers_out.content_length_n = res.GetDetaRef().length();
else
r->headers_out.content_length_n = res.GetContent().length();
ngx_http_send_header(r);
buf = (ngx_buf_t *)ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
if (buf == NULL) {
ngx_log_error(NGX_LOG_ERR,
r->connection->log,
0,
"Failed to allocate response buffer.");
return NGX_ERROR;
}
if (res.GetDetaRef().length() > 0) {
buf->pos = (u_char *)res.GetDetaRef().data();
buf->last = buf->pos + res.GetDetaRef().length();
} else {
buf->pos = (u_char *)res.GetContent().c_str();
buf->last = buf->pos + res.GetContent().length();
}
buf->memory = 1; /* content is in read-only memory */
buf->last_buf = 1; /* there will be no more buffers in the request */
out.buf = buf;
out.next = NULL;
return ngx_http_output_filter(r, &out);
}