本文整理汇总了C++中Transport::setResponse方法的典型用法代码示例。如果您正苦于以下问题:C++ Transport::setResponse方法的具体用法?C++ Transport::setResponse怎么用?C++ Transport::setResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transport
的用法示例。
在下文中一共展示了Transport::setResponse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f_dangling_server_proxy_new_request
bool f_dangling_server_proxy_new_request(const String& host) {
if (host.empty()) {
raise_warning("proxy new request needs host name");
return false;
}
Transport *transport = g_context->getTransport();
if (transport == NULL) {
return false;
}
if (!transport->getHeader(DANGLING_HEADER).empty()) {
// if we are processing a dangling server request, do not do it again
return false;
}
std::string url = std::string("http://") + host.data() + ":" +
boost::lexical_cast<std::string>(RuntimeOption::ServerPort) +
transport->getServerObject();
int code = 0;
std::string error;
StringBuffer response;
HeaderMap headers;
headers[DANGLING_HEADER].push_back("1");
if (!HttpProtocol::ProxyRequest(transport, false, url, code, error,
response, &headers)) {
return false;
}
transport->setResponse(code, "dangling_server_proxy_new_request");
echo(response.detach());
return true;
}
示例2: f_dangling_server_proxy_old_request
bool f_dangling_server_proxy_old_request() {
static bool s_detected_dangling_server = true;
if (!s_detected_dangling_server ||
SatelliteServerInfo::DanglingServerPort == 0) {
return false;
}
Transport *transport = g_context->getTransport();
if (transport == NULL) {
return false;
}
if (!transport->getHeader(DANGLING_HEADER).empty()) {
// if we are processing a dangling server request, do not do it again
return false;
}
std::string url = "http://localhost:" +
boost::lexical_cast<std::string>(SatelliteServerInfo::DanglingServerPort) +
transport->getServerObject();
int code = 0;
std::string error;
StringBuffer response;
HeaderMap headers;
headers[DANGLING_HEADER].push_back("1");
if (!HttpProtocol::ProxyRequest(transport, false, url, code, error,
response, &headers)) {
s_detected_dangling_server = false;
return false;
}
transport->setResponse(code, "dangling_server_proxy_old_request");
echo(response.detach());
return true;
}
示例3: f_http_response_code
Variant f_http_response_code(int response_code /* = 0 */) {
Transport *transport = g_context->getTransport();
if (!transport) {
raise_warning("Unable to access response code, no transport");
return false;
}
int old_code = transport->getResponseCode();
if (response_code) {
transport->setResponse(response_code, "explicit_header_response_code");
}
if (old_code) {
return old_code;
}
return response_code ? true : false;
}
示例4: HHVM_FUNCTION
Variant HHVM_FUNCTION(http_response_code, int response_code /* = 0 */) {
Transport *transport = g_context->getTransport();
if (transport) {
*s_response_code = transport->getResponseCode();
if (response_code) {
transport->setResponse(response_code);
}
}
int old_code = *s_response_code;
if (response_code) {
*s_response_code = response_code;
}
if (old_code) {
return old_code;
}
return response_code ? true : false;
}