首先你需要用一個URL響應過程偵聽器
int progress = 0;
std::string progURL = "http://www.example.com/listener";
std::thread progList = std::thread{&ProgressListener, progURL, std::ref(progress)};
web::http::http_response response(web::http::status_codes::Accepted);
response.headers().add("Location", requURL);
request.reply(response);
然後啓動一個線程,它允許你舉辦一個單獨的偵聽器。
void ProgressListener(std::string progURL, double &progress){
web::http::experimental::listener::http_listener progListener(hostURL);
progListener.support(web::http::methods::GET, [&](web::http::http_request request){
web::http::http_response response;
response.set_status_code(web::http::status_codes::OK);
response.headers().add("Progress", progress); // You can call the header anything pretty much
request.reply(response);
}
}
然後你需要用你的客戶端輪詢這個URL,並提取標題數據。