本文整理汇总了C++中HttpResponse::getBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpResponse::getBuffer方法的具体用法?C++ HttpResponse::getBuffer怎么用?C++ HttpResponse::getBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::getBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}