connection
import std::net::http2::connection; · source
Types
Http2Connection<S>
type struct Http2Connection<S> {
conn: BufStream<S>;
encoder: HpackEncoder;
decoder: HpackDecoder;
is_client: boolean;
next_stream_id: u32;
goaway_received: boolean;
remote_max_frame: u64;
remote_initial_window: i64;
conn_send_window: i64;
stream_send_window: i64;
static new_client(conn: BufStream<S>) -> Http2Connection<S>;
static new_server(conn: BufStream<S>) -> Http2Connection<S>;
connection(mut &this) -> BufStream<S>*;
goaway_seen(&this) -> boolean;
async handshake_client(mut &this) -> Result<(), IoError>
where S: AsyncTransport;
async handshake_server(mut &this) -> Result<(), IoError>
where S: AsyncTransport;
async await_peer_settings(mut &this) -> Result<(), IoError>
where S: AsyncTransport;
queue_settings(mut &this) -> Result<(), IoError>;
process_control(mut &this, fr: &Frame) -> Result<boolean, IoError>;
queue_header_block(mut &this, stream_id: u32, block: Slice<u8>, end_stream: boolean) -> Result<(), IoError>;
async send_body(mut &this, stream_id: u32, body: Array<u8>, end_stream: boolean) -> Result<(), IoError>
where S: AsyncTransport;
async ensure_send_window(mut &this) -> Result<(), IoError>
where S: AsyncTransport;
queue_ack_data(mut &this, stream_id: u32, n: u64) -> Result<(), IoError>;
async request(mut &this, req: Request, scheme: Str, authority: Str) -> Result<Response, IoError>
where S: AsyncTransport;
async read_response(mut &this, sid: u32) -> Result<Response, IoError>
where S: AsyncTransport;
async serve(mut &this, handler: (Request) -> Response) -> Result<(), IoError>
where S: AsyncTransport;
async read_request(mut &this) -> Result<Option<RequestOnStream>, IoError>
where S: AsyncTransport;
async send_response(mut &this, sid: u32, resp: Response) -> Result<(), IoError>
where S: AsyncTransport;
async send_goaway(mut &this, last_stream_id: u32, error_code: u32) -> Result<(), IoError>
where S: AsyncTransport;
encode_request_headers(mut &this, out: mut &Array<u8>, req: &Request, scheme: Str, authority: Str) -> void;
encode_response_headers(mut &this, out: mut &Array<u8>, resp: &Response) -> void;
encode_regular_headers(mut &this, out: mut &Array<u8>, h: &Headers) -> void;
}
One HTTP/2 connection over any async transport S — a TcpStream for h2c, a TlsStream for h2. It owns the HPACK encoder and decoder, performs the connection preface and SETTINGS handshake, and exposes request (client side) and serve (server side). Requests and responses are the same Request / Response types the HTTP/1.1 layer uses, so handlers and clients are written once.
mut conn: Http2Connection<TcpStream> = Http2Connection::<TcpStream>::new_client(stream);
await conn.handshake_client()?;
const first: Response = await conn.request(req_a, Str::new("http"), authority)?;
const second: Response = await conn.request(req_b, Str::new("http"), authority)?;
It owns its BufStream<S>, as WebSocket<S> does and for the same reason: the type carries per-connection protocol state — the HPACK tables, the flow-control windows, the next stream id — and an async method may only re-address its own receiver between polls. Owning the connection is also what gives the read side one buffer for the whole connection: bytes of the next frame that arrived in the same fill as the previous one are still there to be parsed rather than lost. connection() surfaces the transport for socket options or the negotiated ALPN protocol, not for reading or writing.
The write side is synchronous throughout — the queue_* methods only append to the connection's pending buffer — so a whole HEADERS block plus its CONTINUATION fragments is assembled with no suspension point inside it, and the connection suspends exactly once, in flush.
Scope. Streams are processed sequentially within a connection — one outstanding request/response at a time, the common keep-alive pattern. Flow control is honoured in both directions for that single active stream plus the connection window; true concurrent multiplexing and server push are out of scope. goaway_seen() reports whether the peer has signalled it is done; send_goaway says so in the other direction.
Properties
| Property | Type |
|---|---|
conn | BufStream<S> |
encoder | HpackEncoder |
decoder | HpackDecoder |
is_client | boolean |
next_stream_id | u32 |
goaway_received | boolean |
remote_max_frame | u64 |
remote_initial_window | i64 |
conn_send_window | i64 |
stream_send_window | i64 |
Constructors
static new_client(conn: BufStream<S>) -> Http2Connection<S>;
static new_client(conn: BufStream<S>) -> Http2Connection<S>;New client-side connection taking ownership of conn. Call handshake_client before issuing requests.
static new_server(conn: BufStream<S>) -> Http2Connection<S>;
static new_server(conn: BufStream<S>) -> Http2Connection<S>;New server-side connection over an accepted, already-buffered transport.
Methods
connection(mut &this) -> BufStream<S>*;
connection(mut &this) -> BufStream<S>*;The buffered connection, for callers that need the transport itself (socket options, the negotiated ALPN protocol). Not for reading or writing — that would desynchronize the framing.
goaway_seen(&this) -> boolean;
goaway_seen(&this) -> boolean;Has the peer sent a GOAWAY on this connection?
async handshake_client(mut &this) -> Result<(), IoError> where S: AsyncTransport;
async handshake_client(mut &this) -> Result<(), IoError> where S: AsyncTransport;Client preface + SETTINGS exchange. Queues the magic and our SETTINGS and sends both in one flush, then reads frames (acking the peer's SETTINGS) until the peer's initial SETTINGS frame has been seen.
async handshake_server(mut &this) -> Result<(), IoError> where S: AsyncTransport;
async handshake_server(mut &this) -> Result<(), IoError> where S: AsyncTransport;Server side: validate the client preface, send our SETTINGS, then read frames (acking the peer's SETTINGS) until the client's initial SETTINGS frame has been seen.
async await_peer_settings(mut &this) -> Result<(), IoError> where S: AsyncTransport;
async await_peer_settings(mut &this) -> Result<(), IoError> where S: AsyncTransport;Read frames until the peer's initial (non-ACK) SETTINGS frame arrives, handling every control frame that precedes it.
queue_settings(mut &this) -> Result<(), IoError>;
queue_settings(mut &this) -> Result<(), IoError>;Queue our advertised SETTINGS frame. Synchronous; the caller flushes.
process_control(mut &this, fr: &Frame) -> Result<boolean, IoError>;
process_control(mut &this, fr: &Frame) -> Result<boolean, IoError>;Handle a connection-level control frame. Returns true if the frame was fully handled here (SETTINGS, PING, WINDOW_UPDATE, GOAWAY, PRIORITY, PUSH_PROMISE); false for stream frames the caller must process (HEADERS, CONTINUATION, DATA, RST_STREAM).
queue_header_block(mut &this, stream_id: u32, block: Slice<u8>, end_stream: boolean) -> Result<(), IoError>;
queue_header_block(mut &this, stream_id: u32, block: Slice<u8>, end_stream: boolean) -> Result<(), IoError>;Queue a header block on stream_id, splitting into HEADERS + CONTINUATION frames to respect the peer's max frame size. Sets END_STREAM on the HEADERS frame when end_stream is set.
async send_body(mut &this, stream_id: u32, body: Array<u8>, end_stream: boolean) -> Result<(), IoError> where S: AsyncTransport;
async send_body(mut &this, stream_id: u32, body: Array<u8>, end_stream: boolean) -> Result<(), IoError> where S: AsyncTransport;Send a message body as DATA frames on stream_id, honouring the connection and stream send windows and the peer's max frame size, and put everything queued on the wire.
async ensure_send_window(mut &this) -> Result<(), IoError> where S: AsyncTransport;
async ensure_send_window(mut &this) -> Result<(), IoError> where S: AsyncTransport;Wait until both the stream and connection send windows are positive, processing incoming control frames (chiefly WINDOW_UPDATE) while we wait.
queue_ack_data(mut &this, stream_id: u32, n: u64) -> Result<(), IoError>;
queue_ack_data(mut &this, stream_id: u32, n: u64) -> Result<(), IoError>;Queue the WINDOW_UPDATEs that replenish our receive windows after consuming n octets of DATA. Synchronous; the caller flushes.
async request(mut &this, req: Request, scheme: Str, authority: Str) -> Result<Response, IoError> where S: AsyncTransport;
async request(mut &this, req: Request, scheme: Str, authority: Str) -> Result<Response, IoError> where S: AsyncTransport;Issue one request and read its response. scheme is "http" (h2c) or "https" (h2); authority becomes the :authority pseudo- header. Consumes req.
async read_response(mut &this, sid: u32) -> Result<Response, IoError> where S: AsyncTransport;
async read_response(mut &this, sid: u32) -> Result<Response, IoError> where S: AsyncTransport;Read frames until the response on sid completes, assembling its header block and body.
async serve(mut &this, handler: (Request) -> Response) -> Result<(), IoError> where S: AsyncTransport;
async serve(mut &this, handler: (Request) -> Response) -> Result<(), IoError> where S: AsyncTransport;Serve requests on this connection, dispatching each to handler, until the peer closes the connection or sends GOAWAY. Performs the server handshake first.
async read_request(mut &this) -> Result<Option<RequestOnStream>, IoError> where S: AsyncTransport;
async read_request(mut &this) -> Result<Option<RequestOnStream>, IoError> where S: AsyncTransport;Read frames until one stream completes (END_STREAM), returning the assembled request. None means the connection closed cleanly.
async send_response(mut &this, sid: u32, resp: Response) -> Result<(), IoError> where S: AsyncTransport;
async send_response(mut &this, sid: u32, resp: Response) -> Result<(), IoError> where S: AsyncTransport;Send a response on sid. Consumes resp.
async send_goaway(mut &this, last_stream_id: u32, error_code: u32) -> Result<(), IoError> where S: AsyncTransport;
async send_goaway(mut &this, last_stream_id: u32, error_code: u32) -> Result<(), IoError> where S: AsyncTransport;Send a GOAWAY with the given last-stream-id and error code, then stop. Best-effort; transport teardown is the caller's.
encode_request_headers(mut &this, out: mut &Array<u8>, req: &Request, scheme: Str, authority: Str) -> void;
encode_response_headers(mut &this, out: mut &Array<u8>, resp: &Response) -> void;
encode_regular_headers(mut &this, out: mut &Array<u8>, h: &Headers) -> void;
encode_regular_headers(mut &this, out: mut &Array<u8>, h: &Headers) -> void;Emit every stored header except the HTTP/1-only connection- specific fields that are forbidden in HTTP/2 (RFC 7540 section 8.1.2.2).
Constants
Settings
const PREFACE_LEN: u64 = 24;
const LOCAL_HEADER_TABLE_SIZE: u32 = 4096;
const LOCAL_ENABLE_PUSH: u32 = 0;
const LOCAL_INITIAL_WINDOW_SIZE: u32 = 1048576;
const LOCAL_MAX_FRAME_SIZE: u32 = 16384;
const LOCAL_MAX_HEADER_LIST_SIZE: u32 = 262144;
const LOCAL_MAX_BODY_SIZE: u64 = 16777216;
const DEFAULT_CONNECTION_WINDOW: i64 = 65535;
The values advertised in the local SETTINGS frame, and the body cap enforced on the receive side.
type struct Name { ... }
type enum Name { ... }
type trait Name { ... }
type union Name { ... }Begins a type declaration; the keyword that follows says which kind. On its own, type Name = Existing; declares an alias.
type struct Name {
field: Type;
method(&this) -> Ret { ... }
}A value type with named fields and optional methods. Structs live on the stack and are passed by value. Fields are public by default and may carry = default values; methods take their receiver as &this, mut &this, or this.
type struct Http2Connection<S> {
conn: BufStream<S>;
encoder: HpackEncoder;
decoder: HpackDecoder;
is_client: boolean;
next_stream_id: u32;
goaway_received: boolean;
remote_max_frame: u64;
remote_initial_window: i64;
conn_send_window: i64;
stream_send_window: i64;
}type parameter SHttp2Connection.conn: BufStream<S>type struct BufStream<S> {
inner: S;
rbuf: Array<u8>;
rpos: u64;
scratch: Array<u8>;
wbuf: Array<u8>;
}type parameter SHttp2Connection.encoder: HpackEncodertype struct HpackEncoder {
table: DynTable;
}Http2Connection.decoder: HpackDecodertype struct HpackDecoder {
table: DynTable;
hard_max: u64;
}Http2Connection.is_client: booleanHttp2Connection.next_stream_id: u32Http2Connection.goaway_received: booleanHttp2Connection.remote_max_frame: u64Http2Connection.remote_initial_window: i64Http2Connection.conn_send_window: i64Http2Connection.stream_send_window: i64static name(param: Type) -> Ret { ... }A method that belongs to the type rather than an instance, called as Type::name(..). For structs, static new(..) returning a struct literal is the idiomatic constructor.
static Http2Connection::new_client(conn: BufStream<S>) -> Http2Connection<S>New client-side connection taking ownership of conn. Call handshake_client before issuing requests.
(parameter) conn: BufStream<S>type struct Http2Connection<S> {
conn: BufStream<S>;
encoder: HpackEncoder;
decoder: HpackDecoder;
is_client: boolean;
next_stream_id: u32;
goaway_received: boolean;
remote_max_frame: u64;
remote_initial_window: i64;
conn_send_window: i64;
stream_send_window: i64;
}static Http2Connection::new_server(conn: BufStream<S>) -> Http2Connection<S>New server-side connection over an accepted, already-buffered transport.
Http2Connection::connection(mut &this) -> BufStream<S>*The buffered connection, for callers that need the transport itself (socket options, the negotiated ALPN protocol). Not for reading or writing — that would desynchronize the framing.
mut &this
mut &TypeAn exclusive, mutating borrow. As a receiver, mut &this lets the method modify the fields - and callers can see that from the signature alone. As a parameter type, mut &T lets the callee mutate through the reference while the caller keeps ownership.
&this
mut &this
thisThe receiver of a method. Its first parameter declares how the method takes it: &this borrows read-only, mut &this borrows exclusively, and this / mut this move the value in and consume it. In the body, this.field reaches the members.
Http2Connection::goaway_seen(&this) -> booleanHas the peer sent a GOAWAY on this connection?
async function name(param: Type) -> T { ... }Compiles the function into a stackless state machine. Calling it builds a future whose output is the declared return type; nothing runs until that future is polled. Allowed on free functions, methods, and trait methods.
language referenceasync Http2Connection::handshake_client(mut &this) -> Result<(), IoError>
where S: AsyncTransportClient preface + SETTINGS exchange. Queues the magic and our SETTINGS and sends both in one flush, then reads frames (acking the peer's SETTINGS) until the peer's initial SETTINGS frame has been seen.
primitive ()The unit type: a value that carries no information, and the empty tuple. Distinct from void, which is the absence of a value - Result<(), E> succeeds with nothing to return. 0 bytes.
type struct IoError {
kind: IoErrorKind;
os_code: i32;
}where T: Ord + Clone, U: HashConstrains generic parameters to types that implement the listed traits, which is what makes those traits' methods callable on T. Bounds on one parameter join with +; parameters separate with ,. A where on a single method narrows the type's parameter for that method only.
type trait AsyncTransport {
async read_into(mut &this, buf: Array<u8>) -> Transfer;
async write_from(mut &this, buf: Array<u8>) -> Transfer;
}One raw, unbuffered async byte channel: what BufStream<S> needs of a transport, and nothing more.
async Http2Connection::handshake_server(mut &this) -> Result<(), IoError>
where S: AsyncTransportServer side: validate the client preface, send our SETTINGS, then read frames (acking the peer's SETTINGS) until the client's initial SETTINGS frame has been seen.
async Http2Connection::await_peer_settings(mut &this) -> Result<(), IoError>
where S: AsyncTransportRead frames until the peer's initial (non-ACK) SETTINGS frame arrives, handling every control frame that precedes it.
Http2Connection::queue_settings(mut &this) -> Result<(), IoError>Queue our advertised SETTINGS frame. Synchronous; the caller flushes.
Http2Connection::process_control(mut &this, fr: &Frame) -> Result<boolean, IoError>Handle a connection-level control frame. Returns true if the frame was fully handled here (SETTINGS, PING, WINDOW_UPDATE, GOAWAY, PRIORITY, PUSH_PROMISE); false for stream frames the caller must process (HEADERS, CONTINUATION, DATA, RST_STREAM).
(parameter) fr: &Frametype struct Frame {
ftype: u8;
flags: u8;
stream_id: u32;
payload: Array<u8>;
}One decoded frame. Owns its payload bytes; call drop.
Http2Connection::queue_header_block(mut &this, stream_id: u32, block: Slice<u8>, end_stream: boolean) -> Result<(), IoError>Queue a header block on stream_id, splitting into HEADERS + CONTINUATION frames to respect the peer's max frame size. Sets END_STREAM on the HEADERS frame when end_stream is set.
(parameter) stream_id: u32(parameter) block: Slice<u8>type struct Slice<T> {
ptr: T*;
length: u64;
}Slice<T>: a borrowed view into a contiguous sequence.
std::core::slice(parameter) end_stream: booleanasync Http2Connection::send_body(mut &this, stream_id: u32, body: Array<u8>, end_stream: boolean) -> Result<(), IoError>
where S: AsyncTransportSend a message body as DATA frames on stream_id, honouring the connection and stream send windows and the peer's max frame size, and put everything queued on the wire.
(parameter) body: Array<u8>type struct Array<T, A = GlobalAlloc> where A: Allocator {
ptr: T*;
length: i64;
capacity: i64;
alloc: A;
}Array<T, A>: growable, heap-backed, contiguous sequence.
std::collections::arrayasync Http2Connection::ensure_send_window(mut &this) -> Result<(), IoError>
where S: AsyncTransportWait until both the stream and connection send windows are positive, processing incoming control frames (chiefly WINDOW_UPDATE) while we wait.
Http2Connection::queue_ack_data(mut &this, stream_id: u32, n: u64) -> Result<(), IoError>Queue the WINDOW_UPDATEs that replenish our receive windows after consuming n octets of DATA. Synchronous; the caller flushes.
(parameter) n: u64async Http2Connection::request(mut &this, req: Request, scheme: Str, authority: Str) -> Result<Response, IoError>
where S: AsyncTransportIssue one request and read its response. scheme is "http" (h2c) or "https" (h2); authority becomes the :authority pseudo- header. Consumes req.
(parameter) req: Requesttype struct Request {
method: Method;
path: String;
version: String;
headers: Headers;
body: Array<u8>;
params: HashMap<String, String>;
}HTTP request.
std::net::http::request(parameter) scheme: Strtype struct Str {
bytes: u8*;
length: u64;
}Str: a borrowed UTF-8 string slice.
std::collections::str(parameter) authority: Strtype struct Response {
status: StatusCode;
version: String;
headers: Headers;
body: Array<u8>;
}HTTP response.
std::net::http::responseasync Http2Connection::read_response(mut &this, sid: u32) -> Result<Response, IoError>
where S: AsyncTransportRead frames until the response on sid completes, assembling its header block and body.
(parameter) sid: u32async Http2Connection::serve(mut &this, handler: (Request) -> Response) -> Result<(), IoError>
where S: AsyncTransportServe requests on this connection, dispatching each to handler, until the peer closes the connection or sends GOAWAY. Performs the server handshake first.
(parameter) handler: (Request) -> Responseasync Http2Connection::read_request(mut &this) -> Result<Option<RequestOnStream>, IoError>
where S: AsyncTransportRead frames until one stream completes (END_STREAM), returning the assembled request. None means the connection closed cleanly.
type struct RequestOnStream {
stream_id: u32;
req: Request;
}A decoded request paired with the stream it arrived on. A plain carrier with no destructor: serve always moves req out to the handler, so the field is consumed exactly once.
async Http2Connection::send_response(mut &this, sid: u32, resp: Response) -> Result<(), IoError>
where S: AsyncTransportSend a response on sid. Consumes resp.
(parameter) resp: Responseasync Http2Connection::send_goaway(mut &this, last_stream_id: u32, error_code: u32) -> Result<(), IoError>
where S: AsyncTransportSend a GOAWAY with the given last-stream-id and error code, then stop. Best-effort; transport teardown is the caller's.
(parameter) last_stream_id: u32(parameter) error_code: u32Http2Connection::encode_request_headers(mut &this, out: mut &Array<u8>, req: &Request, scheme: Str, authority: Str) -> void(parameter) out: mut &Array<u8>(parameter) req: &RequestHttp2Connection::encode_response_headers(mut &this, out: mut &Array<u8>, resp: &Response) -> void(parameter) resp: &ResponseHttp2Connection::encode_regular_headers(mut &this, out: mut &Array<u8>, h: &Headers) -> voidEmit every stored header except the HTTP/1-only connection- specific fields that are forbidden in HTTP/2 (RFC 7540 section 8.1.2.2).
(parameter) h: &Headerstype struct Headers {
inner: HashMap<String, String>;
}HTTP headers: case-insensitive name/value map.
std::net::http::headersmut name: Type = value;A mutable binding, reassignable after declaration - mutability is opt-in, const is the default. At module level it declares mutable global state. Before & it marks an exclusive reference or receiver instead.
mut conn: Http2Connection<TcpStream>type struct TcpStream {
fd: i32;
}static Http2Connection::new_client(conn: BufStream<S>) -> Http2Connection<S>New client-side connection taking ownership of conn. Call handshake_client before issuing requests.
await futureSuspends the enclosing async body until the operand - which must implement Future - completes, and evaluates to its output. A prefix operator allowed anywhere an expression is (conditions, arms, guards), but only inside async code.
mut conn: Http2Connection<TcpStream>async Http2Connection::handshake_client(mut &this) -> Result<(), IoError>
where S: AsyncTransportClient preface + SETTINGS exchange. Queues the magic and our SETTINGS and sends both in one flush, then reads frames (acking the peer's SETTINGS) until the peer's initial SETTINGS frame has been seen.
std::net::http2::connectionvalue?Error propagation. On a Result<T, E> it yields the T of an Ok and otherwise returns the Err(e) from the enclosing function unchanged; on an Option<T> it yields the T of a Some or returns None. The enclosing function must return a matching Result / Option.
const NAME: Type = value;At module level, a true compile-time constant, conventionally SCREAMING_SNAKE_CASE. (mut at module level declares mutable global state instead.)
const first: Responseasync Http2Connection::request(mut &this, req: Request, scheme: Str, authority: Str) -> Result<Response, IoError>
where S: AsyncTransportIssue one request and read its response. scheme is "http" (h2c) or "https" (h2); authority becomes the :authority pseudo- header. Consumes req.
static Str::new(text: string) -> StrConstruct from a NUL-terminated C-style string literal. The caller certifies that text is valid UTF-8 and outlives this view. The NUL terminator is not included in the view.
const second: Responseconst PREFACE_LEN: u64 = 24;const LOCAL_HEADER_TABLE_SIZE: u32 = 4096;const LOCAL_ENABLE_PUSH: u32 = 0;const LOCAL_INITIAL_WINDOW_SIZE: u32 = 1048576;const LOCAL_MAX_FRAME_SIZE: u32 = 16384;const LOCAL_MAX_HEADER_LIST_SIZE: u32 = 262144;const LOCAL_MAX_BODY_SIZE: u64 = 16777216;const DEFAULT_CONNECTION_WINDOW: i64 = 65535;import a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).
namespace std::net::http2;net::http2: HTTP/2 (RFC 7540) with HPACK header compression (RFC 7541).
module pagetype struct TlsStream {
ssl: void*;
inner: TcpStream;
}async Http2Connection::serve(mut &this, handler: (Request) -> Response) -> Result<(), IoError>
where S: AsyncTransportServe requests on this connection, dispatching each to handler, until the peer closes the connection or sends GOAWAY. Performs the server handshake first.
type struct WebSocket<S> {
conn: BufStream<S>;
is_client: boolean;
closed: boolean;
}Http2Connection::connection(mut &this) -> BufStream<S>*The buffered connection, for callers that need the transport itself (socket options, the negotiated ALPN protocol). Not for reading or writing — that would desynchronize the framing.
std::net::http2::connectionHttp2Connection::goaway_seen(&this) -> booleanHas the peer sent a GOAWAY on this connection?
std::net::http2::connectionasync Http2Connection::send_goaway(mut &this, last_stream_id: u32, error_code: u32) -> Result<(), IoError>
where S: AsyncTransportSend a GOAWAY with the given last-stream-id and error code, then stop. Best-effort; transport teardown is the caller's.
std::net::http2::connectionHttp2Connection.conn: BufStream<S>Http2Connection.encoder: HpackEncoderHttp2Connection.decoder: HpackDecoderHttp2Connection.is_client: booleanHttp2Connection.next_stream_id: u32Http2Connection.goaway_received: booleanHttp2Connection.remote_max_frame: u64Http2Connection.remote_initial_window: i64Http2Connection.conn_send_window: i64Http2Connection.stream_send_window: i64static Http2Connection::new_server(conn: BufStream<S>) -> Http2Connection<S>New server-side connection over an accepted, already-buffered transport.
std::net::http2::connectionasync Http2Connection::handshake_server(mut &this) -> Result<(), IoError>
where S: AsyncTransportServer side: validate the client preface, send our SETTINGS, then read frames (acking the peer's SETTINGS) until the client's initial SETTINGS frame has been seen.
std::net::http2::connectionasync Http2Connection::await_peer_settings(mut &this) -> Result<(), IoError>
where S: AsyncTransportRead frames until the peer's initial (non-ACK) SETTINGS frame arrives, handling every control frame that precedes it.
std::net::http2::connectionHttp2Connection::queue_settings(mut &this) -> Result<(), IoError>Queue our advertised SETTINGS frame. Synchronous; the caller flushes.
std::net::http2::connectionHttp2Connection::process_control(mut &this, fr: &Frame) -> Result<boolean, IoError>Handle a connection-level control frame. Returns true if the frame was fully handled here (SETTINGS, PING, WINDOW_UPDATE, GOAWAY, PRIORITY, PUSH_PROMISE); false for stream frames the caller must process (HEADERS, CONTINUATION, DATA, RST_STREAM).
std::net::http2::connectionHttp2Connection::queue_header_block(mut &this, stream_id: u32, block: Slice<u8>, end_stream: boolean) -> Result<(), IoError>Queue a header block on stream_id, splitting into HEADERS + CONTINUATION frames to respect the peer's max frame size. Sets END_STREAM on the HEADERS frame when end_stream is set.
RequestOnStream.stream_id: u32async Http2Connection::send_body(mut &this, stream_id: u32, body: Array<u8>, end_stream: boolean) -> Result<(), IoError>
where S: AsyncTransportSend a message body as DATA frames on stream_id, honouring the connection and stream send windows and the peer's max frame size, and put everything queued on the wire.
async Http2Connection::ensure_send_window(mut &this) -> Result<(), IoError>
where S: AsyncTransportWait until both the stream and connection send windows are positive, processing incoming control frames (chiefly WINDOW_UPDATE) while we wait.
std::net::http2::connectionHttp2Connection::queue_ack_data(mut &this, stream_id: u32, n: u64) -> Result<(), IoError>Queue the WINDOW_UPDATEs that replenish our receive windows after consuming n octets of DATA. Synchronous; the caller flushes.
RequestOnStream.req: Requestasync Http2Connection::read_response(mut &this, sid: u32) -> Result<Response, IoError>
where S: AsyncTransportRead frames until the response on sid completes, assembling its header block and body.
async Http2Connection::read_request(mut &this) -> Result<Option<RequestOnStream>, IoError>
where S: AsyncTransportRead frames until one stream completes (END_STREAM), returning the assembled request. None means the connection closed cleanly.
Option::Noneasync Http2Connection::send_response(mut &this, sid: u32, resp: Response) -> Result<(), IoError>
where S: AsyncTransportSend a response on sid. Consumes resp.
Http2Connection::encode_request_headers(mut &this, out: mut &Array<u8>, req: &Request, scheme: Str, authority: Str) -> voidHttp2Connection::encode_response_headers(mut &this, out: mut &Array<u8>, resp: &Response) -> voidHttp2Connection::encode_regular_headers(mut &this, out: mut &Array<u8>, h: &Headers) -> voidEmit every stored header except the HTTP/1-only connection- specific fields that are forbidden in HTTP/2 (RFC 7540 section 8.1.2.2).
std::net::http2::connection