0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 14:38:57 +02:00

ircd: Tweak client stack error related; fix missing content-type; assert all responses.

This commit is contained in:
Jason Volk 2018-03-09 11:35:55 -08:00
parent b1a4ca6852
commit 27b01a58eb
2 changed files with 18 additions and 11 deletions

View file

@ -574,19 +574,17 @@ catch(const boost::system::system_error &e)
close(net::dc::RST, net::close_ignore);
return false;
}
#ifndef RB_DEBUG
catch(const std::exception &e)
{
log::error
{
"client[%s] [500 Internal Error]: %s"
"client[%s] [500 Internal Error]: %s",
string(remote(*this)),
e.what())
e.what()
};
return false;
}
#endif
/// Handle a single request within the client main() loop.
///
@ -643,22 +641,25 @@ catch(const boost::system::system_error &e)
resource::response
{
*this, {}, {}, http::REQUEST_TIMEOUT
*this, 0L, {}, http::REQUEST_TIMEOUT
};
return false;
}
catch(const ircd::error &e)
{
log::error("socket(%p) local[%s] remote[%s]: %s",
sock.get(),
string(local(*this)),
string(remote(*this)),
e.what());
log::error
{
"socket(%p) local[%s] remote[%s]: %s",
sock.get(),
string(local(*this)),
string(remote(*this)),
e.what()
};
resource::response
{
*this, e.what(), {}, http::INTERNAL_SERVER_ERROR
*this, e.what(), "text/html; charset=utf8", http::INTERNAL_SERVER_ERROR
};
throw;

View file

@ -605,6 +605,8 @@ ircd::resource::response::response(client &client,
const http::code &code,
const vector_view<const http::header> &headers)
{
assert(empty(content) || !empty(content_type));
// contents of this buffer get copied again when further passed to
// response{}; we can get this off the stack if that remains true.
thread_local char buffer[4_KiB];
@ -626,6 +628,8 @@ ircd::resource::response::response(client &client,
const http::code &code,
const string_view &headers)
{
assert(empty(content) || !empty(content_type));
// Head gets sent
response
{
@ -647,6 +651,8 @@ ircd::resource::response::response(client &client,
const http::code &code,
const string_view &headers)
{
assert(!content_length || !empty(content_type));
const auto request_time
{
client.timer.at<microseconds>().count()