pub enum Session {
Connected,
StatelessRpc,
}Expand description
How much of a conversation one call to a state machine gets to see.
§Why this exists, and why it is not a second implementation
Over SSH the client and the server hold one connection for the whole
exchange: the advertisement, every have/want round and the packfile all
travel down it, and the server’s negotiation state lives in the stack frame
that is serving it.
Smart HTTP has no such frame. Each POST is an independent request that may
land on a different worker, so the client re-sends its whole request on
every round and the server must answer one round and stop. That is git’s
--stateless-rpc, and it is the one behavioural difference between the two
transports. Everything else — the framing, ls-refs, the negotiation, the
pack writer — is identical, which is why gunnar-http wraps these state
machines instead of restating them (one implementation).
The difference is exactly three things:
Connected | StatelessRpc | |
|---|---|---|
| who writes the advertisement | this crate, inline | GET /info/refs, a separate call to upload_pack::UploadPack::advertise |
| v2 commands per call | until the client stops | exactly one |
v0 have rounds per call | until the client sends done | one; a round with no done answers ACK/NAK and returns |
A Session is not a protocol version and does not interact with one:
both v0 and v2 ride both transports.
Variants§
Connected
One connection carries the whole conversation. SSH, ext::, a pipe.
StatelessRpc
One call is one request and one response; the next round, if there is one, arrives on a different connection. Smart HTTP.
Implementations§
Source§impl Session
impl Session
Sourcepub fn advertises_inline(self) -> bool
pub fn advertises_inline(self) -> bool
Does this session write its own advertisement before reading?
Over HTTP it does not: the advertisement is a different request
(GET /info/refs?service=…), and a POST body that began with one
would put the whole ref list in front of every negotiation round.
Sourcepub fn is_stateless(self) -> bool
pub fn is_stateless(self) -> bool
Must this call return after answering one round?