mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 00:14:07 +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
|
bool
|
||||||
ircd::handle_request(client &client,
|
ircd::handle_request(client &client,
|
||||||
parse::capstan &pc)
|
parse::capstan &pc)
|
||||||
|
try
|
||||||
{
|
{
|
||||||
client.request_timer = ircd::timer{};
|
client.request_timer = ircd::timer{};
|
||||||
const socket::scope_timeout timeout
|
const socket::scope_timeout timeout
|
||||||
|
@ -388,6 +389,32 @@ ircd::handle_request(client &client,
|
||||||
|
|
||||||
return ret;
|
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
|
void
|
||||||
ircd::handle_request(client &client,
|
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 write_closure &write_closure,
|
||||||
const proffer &proffer,
|
const proffer &proffer,
|
||||||
const headers::closure &headers_closure)
|
const headers::closure &headers_closure)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
const head h{pc, headers_closure};
|
const head h{pc, headers_closure};
|
||||||
const char *const content_mark(pc.parsed);
|
const char *const content_mark(pc.parsed);
|
||||||
|
@ -287,20 +286,6 @@ try
|
||||||
if(c)
|
if(c)
|
||||||
*c = content{pc, h};
|
*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,
|
ircd::http::request::request(const string_view &host,
|
||||||
const string_view &method,
|
const string_view &method,
|
||||||
|
|
Loading…
Reference in a new issue