mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::http: Move request error handlers out of http (to client).
This commit is contained in:
parent
91ee213c86
commit
acff6139e9
2 changed files with 27 additions and 15 deletions
|
@ -363,6 +363,7 @@ catch(const std::exception &e)
|
|||
bool
|
||||
ircd::handle_request(client &client,
|
||||
parse::capstan &pc)
|
||||
try
|
||||
{
|
||||
client.request_timer = ircd::timer{};
|
||||
const socket::scope_timeout timeout
|
||||
|
@ -388,6 +389,32 @@ ircd::handle_request(client &client,
|
|||
|
||||
return ret;
|
||||
}
|
||||
catch(const http::error &e)
|
||||
{
|
||||
log::error("client[%s]: %s",
|
||||
string(remote(client)),
|
||||
e.what());
|
||||
|
||||
http::response
|
||||
{
|
||||
e.code, e.content, write_closure(client)
|
||||
};
|
||||
|
||||
throw;
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
log::error("client[%s]: %s",
|
||||
string(remote(client)),
|
||||
e.what());
|
||||
|
||||
http::response
|
||||
{
|
||||
http::INTERNAL_SERVER_ERROR, e.what(), write_closure(client)
|
||||
};
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
void
|
||||
ircd::handle_request(client &client,
|
||||
|
|
15
ircd/http.cc
15
ircd/http.cc
|
@ -270,7 +270,6 @@ ircd::http::request::request(parse::capstan &pc,
|
|||
const write_closure &write_closure,
|
||||
const proffer &proffer,
|
||||
const headers::closure &headers_closure)
|
||||
try
|
||||
{
|
||||
const head h{pc, headers_closure};
|
||||
const char *const content_mark(pc.parsed);
|
||||
|
@ -287,20 +286,6 @@ try
|
|||
if(c)
|
||||
*c = content{pc, h};
|
||||
}
|
||||
catch(const http::error &e)
|
||||
{
|
||||
if(write_closure)
|
||||
http::response{e.code, e.content, write_closure};
|
||||
|
||||
throw;
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
if(write_closure)
|
||||
http::response{http::INTERNAL_SERVER_ERROR, e.what(), write_closure};
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
ircd::http::request::request(const string_view &host,
|
||||
const string_view &method,
|
||||
|
|
Loading…
Reference in a new issue