pub fn try_upgrade(
req: &HttpRequest,
upgrades: &BTreeMap<String, UpgradeHandler>,
) -> Option<Result<(String, UpgradeHandler), ()>>Expand description
The RFC 6455 handshake decision for req against upgrades, in ONE place so every tier that
drives its own connection loop (the tokio serve_connection below; the interpreter, which is
!Send and never reaches serve_connection at all) reaches the exact same answer rather than
hand-copying the accept-key derivation and the 101 response line a second time.
None:reqdoes not ask to upgrade a registered path at all (wrong method, noUpgrade: websocketheader, or a path nothing is registered for) — proceed to the ordinary request path exactly as ifupgradeswere empty.Some(Ok((response, handler))): the handshake is complete — writeresponseverbatim, then hand the raw connection tohandler.Some(Err(())): the path/method/header matched a registered upgrade, but the handshake itself could not be completed (noSec-WebSocket-Key, or therelayfeature is not compiled in). The connection must be DROPPED WITH NO RESPONSE — never a fallback to the ordinary handler, and never a generic error page (seeUpgradeHandler’s own doc comment: this is what actually gates the behaviour, not a second check at the call site).