Log(LogInformation, "HttpServerConnection")
<< "HTTP client disconnected (from " << m_PeerAddress << ")";
- try {
- m_Stream->next_layer().async_shutdown(yc);
- } catch (...) {
- }
+ boost::system::error_code ec;
- try {
- m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both);
- } catch (...) {
- }
+ m_Stream->next_layer().async_shutdown(yc[ec]);
- try {
- m_Stream->lowest_layer().cancel();
- } catch (...) {
- }
+ m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec);
+
+ m_Stream->lowest_layer().cancel(ec);
m_CheckLivenessTimer.cancel();
bool httpError = true;
try {
- try {
- http::async_read_header(stream, buf, parser, yc);
- } catch (const boost::system::system_error& ex) {
+ boost::system::error_code ec;
+
+ http::async_read_header(stream, buf, parser, yc[ec]);
+
+ if (ec) {
/**
* Unfortunately there's no way to tell an HTTP protocol error
* from an error on a lower layer:
*
* <https://github.com/boostorg/beast/issues/643>
*/
- throw std::invalid_argument(ex.what());
+ throw std::invalid_argument(ec.message());
}
httpError = false;
response.set(http::field::connection, "close");
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return false;
}
response.result(http::status::continue_);
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
}
}
response.set(http::field::content_length, response.body().size());
response.set(http::field::connection, "close");
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return false;
}
response.set(http::field::content_length, response.body().size());
response.set(http::field::connection, "close");
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return false;
}
response.set(http::field::content_length, response.body().size());
}
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return false;
}
parser.body_limit(maxSize);
}
- try {
- http::async_read(stream, buf, parser, yc);
- } catch (const boost::system::system_error& ex) {
+ boost::system::error_code ec;
+
+ http::async_read(stream, buf, parser, yc[ec]);
+
+ if (ec) {
/**
* Unfortunately there's no way to tell an HTTP protocol error
* from an error on a lower layer:
if (parser.get()[http::field::accept] == "application/json") {
HttpUtility::SendJsonBody(response, nullptr, new Dictionary({
{ "error", 400 },
- { "status", String("Bad Request: ") + ex.what() }
+ { "status", String("Bad Request: ") + ec.message() }
}));
} else {
response.set(http::field::content_type, "text/html");
- response.body() = String("<h1>Bad Request</h1><p><pre>") + ex.what() + "</pre></p>";
+ response.body() = String("<h1>Bad Request</h1><p><pre>") + ec.message() + "</pre></p>";
response.set(http::field::content_length, response.body().size());
}
response.set(http::field::connection, "close");
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return false;
}
HttpUtility::SendJsonError(response, nullptr, 500, "Unhandled exception" , DiagnosticInformation(ex));
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return true;
}
return false;
}
- http::async_write(stream, response, yc);
- stream.async_flush(yc);
+ boost::system::error_code ec;
+
+ http::async_write(stream, response, yc[ec]);
+ stream.async_flush(yc[ec]);
return true;
}