如何遍历 boost::beast HTTP 响应头
iterate_response_headers.cpp
// Read & parse the response
beast::flat_buffer buffer;
http::response<http::dynamic_body> res;
http::read(stream, buffer, res);
// 遍历响应头
for (auto it = res.begin(); it != res.end(); ++it) {
std::cout << it->name_string() << ": " << it->value() << "\n";
}
// ... 或获取一个特定的头
cout << res["Content-Length"] << endl;If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow