本文整理汇总了C++中HttpResponse::getStatusLine方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpResponse::getStatusLine方法的具体用法?C++ HttpResponse::getStatusLine怎么用?C++ HttpResponse::getStatusLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::getStatusLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_response
void print_response(HttpResponse& response, TcpClientSocket& socket) {
std::cout << narrow(widen(response.getStatusLine(), CP_UTF8), CP_OEMCP) << std::endl;
auto headers = response.getHeaders();
for (auto it = std::begin(headers), eit = std::end(headers); it != eit; ++it) {
for (auto vit = std::begin(it->second), veit = std::end(it->second); vit != veit; ++vit) {
std::cout << it->first << ": " << *vit << std::endl;
}
}
std::cout << "======END OF HEADERS======" << std::endl;
auto& buffer = response.getBuffer();
if (response.getIsChunked()) {
std::cout << "[[CHUNKED ENCODING]]" << std::endl;
for (auto chunk = buffer.getchunk(); !chunk.empty(); chunk = buffer.getchunk()) {
std::cout << chunk;
}
std::cout << "[[TRAILING HEADERS]]" << std::endl;
for (auto th = buffer.getline(); !th.empty(); th = buffer.getline()) {
std::cout << th << std::endl;
}
}
else if (HttpResponse::nlen != response.getContentLength()) {
std::cout << "[[EXACTLY " << response.getContentLength() << " BYTES]]" << std::endl;
std::cout << buffer.getcount(response.getContentLength()) << std::endl;
}
else {
std::vector<BYTE> buff(8 * 1024, 0);
for (auto last = socket.recv_upto(std::begin(buff), std::end(buff));
last != std::begin(buff); last = socket.recv_upto(std::begin(buff), std::end(buff))) {
std::cout << std::string(std::begin(buff), last);
}
}
std::cout << std::endl << "======END OF RESPONSE======" << std::endl;
}
示例2: mod_ffeadcpp_method_handler
static int mod_ffeadcpp_method_handler (request_rec *r)
{
string port = CastUtil::lexical_cast<string>(r->server->port);
//signal(SIGSEGV,signalSIGSEGV);
string content;
apr_bucket_brigade *bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
for ( ; ; ) {
apr_bucket* b ;
bool done = false;
ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES, APR_BLOCK_READ, HUGE_STRING_LEN);
for ( b = APR_BRIGADE_FIRST(bb);b != APR_BRIGADE_SENTINEL(bb);b = APR_BUCKET_NEXT(b) )
{
size_t bytes ;
const char* buf = "\0";
if ( APR_BUCKET_IS_EOS(b) )
{
done = true;
}
else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ)== APR_SUCCESS )
{
content += string(buf, 0, bytes);
}
}
if (done)
break;
else
apr_brigade_cleanup(bb) ;
}
apr_brigade_destroy(bb) ;
HttpRequest* hreq= new HttpRequest();
string cntpath = serverRootDirectory + "web/";
string webpath = "URL" + cntpath;
MyReq* req = new MyReq();
req->r = r;
req->htreq = hreq;
apr_table_do(iterate_func, req, r->headers_in, NULL);
ip_address = hreq->getHeader(HttpRequest::Host);
string tipaddr = ip_address;
if(port!="80")
tipaddr += (":" + port);
ConfigurationData::getInstance()->ip_address = tipaddr;
string contret;
if(content!="")
{
contret = hreq->buildRequest("Content",content.c_str());
fprintf(stderr,contret.c_str());
fflush(stderr);
}
hreq->buildRequest(webpath.c_str(),r->uri);
hreq->buildRequest("Method",r->method);
if(r->args != NULL && r->args[0] != '\0')
{
hreq->buildRequest("GetArguments",r->args);
}
hreq->buildRequest("HttpVersion", r->protocol);
HttpResponse respo = service(hreq);
string h1 = respo.generateResponse(hreq->getMethod(), hreq, false);
for (int var = 0; var < (int)respo.getCookies().size(); var++)
{
apr_table_add(r->headers_out, "Set-cookie", respo.getCookies().at(var).c_str());
}
r->status_line = respo.getStatusLine().c_str();
if(respo.getHeader(HttpResponse::ContentType)!="")
{
r->content_type = respo.getHeader(HttpResponse::ContentType).c_str();
}
r->clength = h1.length();
fprintf(stderr,"\n\n\n\n--------------------------------------------\n");
fprintf(stderr,hreq->getUrl().c_str());
fprintf(stderr,"\n");
string star = hreq->toString();
fprintf(stderr,star.c_str());
fprintf(stderr,"\n--------------------------------------------\n");
fprintf(stderr,contret.c_str());
fflush(stderr);
fprintf(stderr,"\n\n");
fprintf(stderr,content.c_str());
fprintf(stderr,"\n");
fprintf(stderr,"ip_address = %s", tipaddr.c_str());
fprintf(stderr,"\n");
fprintf(stderr,"\n--------------------------------------------\n\n\n\n");
fflush(stderr);
fprintf(stderr, h1.c_str());
fflush(stderr);
delete hreq;
delete req;
if(h1!="")
{
//.........这里部分代码省略.........