This commit is contained in:
eidheim 2020-02-19 18:04:05 +01:00
commit f4ebb57420

View file

@ -432,9 +432,9 @@ namespace SimpleWeb {
std::shared_ptr<Response> response; std::shared_ptr<Response> response;
std::promise<std::shared_ptr<Response>> response_promise; std::promise<std::shared_ptr<Response>> response_promise;
bool stop_future_handlers = false; auto stop_future_handlers = std::make_shared<bool>(false);
request(method, path, content, header, [&response, &response_promise, &stop_future_handlers](std::shared_ptr<Response> response_, error_code ec) { request(method, path, content, header, [&response, &response_promise, stop_future_handlers](std::shared_ptr<Response> response_, error_code ec) {
if(stop_future_handlers) if(*stop_future_handlers)
return; return;
if(!response) if(!response)
@ -455,7 +455,7 @@ namespace SimpleWeb {
if(ec) { if(ec) {
response_promise.set_exception(std::make_exception_ptr(system_error(ec))); response_promise.set_exception(std::make_exception_ptr(system_error(ec)));
stop_future_handlers = true; *stop_future_handlers = true;
} }
else if(response_->content.end) else if(response_->content.end)
response_promise.set_value(response); response_promise.set_value(response);