pub struct HttpSession { /* private fields */ }Expand description
One session’s state on an HTTP connection.
Holds the negotiated PeerSession beside the tail its server-initiated
messages go on, because the router is generic over the stored type and a
PeerSession alone cannot answer EventSource::tail.
The peer starts at the ceiling profile and is replaced by
Dispatcher::handshake’s return once initialize arrives. That ordering
is not incidental: a RequestContext needs a PeerSession to exist before
dispatch, and the handshake is the call that produces one.
Implementations§
Source§impl HttpSession
impl HttpSession
Sourcepub fn peer(&self) -> PeerSession
pub fn peer(&self) -> PeerSession
This session’s peer.
The same state as Self::peer_of and for the same reason: a task
that outlives the request it was spawned for has to keep reading the
session’s profile rather than a borrow of a body that is gone.
Trait Implementations§
Source§impl Debug for HttpSession
impl Debug for HttpSession
Source§impl EventSource for HttpSession
impl EventSource for HttpSession
Source§impl RequestHandler<HttpSession> for HttpHandler
impl RequestHandler<HttpSession> for HttpHandler
Source§fn unsessioned(&self, body: &[u8], headers: &HeaderMap) -> Unsessioned
fn unsessioned(&self, body: &[u8], headers: &HeaderMap) -> Unsessioned
What a body means when the request named no session.
Three arms, and which one a body falls in is a wire-format question this method can answer on its own:
initializeopens a session. It is the only method that does.- A body whose
params._metanamesPROTOCOL_VERSION_KEYis a SEP-2575 stateless request. It carries its own revision and its own capabilities, so it needs no session and is served against its own profile. - Anything else is a stateful call missing its header, which the router
answers with a
400and never hands here — so returningUnsessioned::NeedsSessionfor it is not a guess, it is the arm that produces that400.
The version key is what makes a body self-describing, and it is the only member that can: capabilities without a revision would not say which gates the answer is read against.
This runs on every sessionless POST, so the check is a lookup and not a
parse — a full RequestMeta::read would decode the whole body only
for a caller with a session header to throw it away.
Source§fn dispatch(
&self,
call: Inbound<'_, HttpSession>,
) -> impl Future<Output = Result<Response, Refusal>> + Send
fn dispatch( &self, call: Inbound<'_, HttpSession>, ) -> impl Future<Output = Result<Response, Refusal>> + Send
Runs one request, and answers it.
The refusal channel is a Refusal: there is no other, and an adapter
that cannot answer a request has exactly one honest way to say so. Note
that a protocol refusal — an unknown method, a tool that does not
exist — is not one. Those are answered in the body with a JSON-RPC error
object, because the peer asked a well-formed question and the answer is
that no such thing exists.