如何遍历 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;

Check out similar posts by category: Boost, C/C++