kube_portforward/subprotocol.rs
1/// Protocol negotiated for a port-forward session.
2///
3/// Both variants speak the SPDY/3.1 frame format on the wire. They only
4/// differ in how frames reach the apiserver: tunnelled inside WebSocket
5/// binary messages, or sent straight over a raw HTTP/1.1 upgrade.
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7#[non_exhaustive]
8pub enum Subprotocol {
9 /// `SPDY/3.1+portforward.k8s.io` — SPDY frames tunnelled inside
10 /// WebSocket binary messages. Negotiated via `Sec-WebSocket-Protocol`
11 Spdy31Tunnel,
12 /// Legacy SPDY/3.1 over a raw HTTP upgrade ( without WebSocket).
13 /// Falls back here when the apiserver rejects the upgrade
14 LegacySpdy,
15}
16
17impl std::fmt::Display for Subprotocol {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 match self {
20 Self::Spdy31Tunnel => f.write_str("SPDY/3.1+ws"),
21 Self::LegacySpdy => f.write_str("SPDY/3.1"),
22 }
23 }
24}