pub async fn authenticate(
__arg0: State<Arc<ApiCredential>>,
request: Request,
next: Next,
) -> ResponseExpand description
Admit a request that presented the credential in force, and refuse every other before anything reads it.
Exactly one Authorization header, spelled Bearer and then the
credential. Two headers, another scheme, another spelling of this one, and a
credential that is not the one in force are all the same refusal, which says
what to present and nothing about what was presented.
The refusal is decided on the head alone, and the body is then drained, up
to BODY_BOUND, before it is answered. Nothing reads what is
drained: a connection closed with a body still unread on it is closed with
a reset rather than an end, and a caller on Windows — where a reset discards
everything received and not yet read — then reads the abort in place of the
401 that was already on its way. Linux hands over what was queued first,
which is why the same race is only ever seen there.