0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-07 12:38:56 +02:00

ircd:Ⓜ️:fed::well_known: Use proper http::category; minor split/reorg.

This commit is contained in:
Jason Volk 2022-08-17 11:27:07 -07:00
parent 84fcffe331
commit 13cd2656c9

View file

@ -14,6 +14,7 @@ namespace ircd::m::fed::well_known
static void submit(request &);
static void receive(request &);
static void finish(request &);
static bool redirect(request &);
static bool handle(request &);
static void worker();
@ -377,20 +378,35 @@ catch(const std::exception &e)
};
}
/// Returns true if the request is done with either success or error; false
/// if the request resubmitted itself.
bool
ircd::m::fed::well_known::handle(request &req)
try
{
receive(req);
// Successful result
if(likely(req.code < 300))
return true;
// Handle redirection.
if(http::category(req.code) == http::category::REDIRECT)
return redirect(req);
// Successful error; bail
if(req.code >= 400)
return true;
return true;
}
catch(const std::exception &e)
{
log::derror
{
log, "%s handling :%s",
req.target,
e.what(),
};
return true;
}
bool
ircd::m::fed::well_known::redirect(request &req)
{
// Indirection code, but no location response header
if(!req.location)
return true;
@ -411,17 +427,6 @@ try
submit(req);
return false;
}
catch(const std::exception &e)
{
log::derror
{
log, "%s handling :%s",
req.target,
e.what(),
};
return true;
}
void
ircd::m::fed::well_known::finish(request &req)