Expand description
Sans-IO HTTP/2 client framing layer.
This crate provides a pure sans-IO HTTP/2 client framing layer. It has
zero runtime dependencies – the caller feeds bytes in via recv() and
pulls bytes out via take_pending_send().
§Architecture
TCP + TLS bytes
|
+----v----------+
| ringline-h2 | HTTP/2 framing + HPACK
| H2Connection | H2Event: Response, Data, Trailers, etc.
+---------------+§Example
ⓘ
use ringline_h2::{H2Connection, H2Event, HeaderField, Settings};
let mut h2 = H2Connection::new(Settings::client_default());
// Send the connection preface to the transport.
let preface = h2.take_pending_send();
transport_send(&preface);
// Send a GET request.
let stream_id = h2.send_request(&[
HeaderField::new(b":method", b"GET"),
HeaderField::new(b":path", b"/"),
HeaderField::new(b":scheme", b"https"),
HeaderField::new(b":authority", b"example.com"),
], true)?;
transport_send(&h2.take_pending_send());
// Feed received bytes.
h2.recv(&received_data)?;
// Drain events.
while let Some(event) = h2.poll_event() {
match event {
H2Event::Response { stream_id, headers, end_stream } => { /* ... */ }
H2Event::Data { stream_id, data, end_stream } => { /* ... */ }
_ => {}
}
}Re-exports§
pub use connection::H2Connection;pub use connection::H2Event;pub use error::ErrorCode;pub use error::H2Error;pub use frame::Frame;pub use hpack::HeaderField;pub use settings::Settings;
Modules§
- connection
- HTTP/2 client connection state machine.
- error
- flowcontrol
- HTTP/2 flow control window tracking (RFC 7540 Section 6.9).
- frame
- HTTP/2 frame encoding/decoding (RFC 7540 Section 4).
- hpack
- HPACK header compression (RFC 7541).
- settings
- HTTP/2 SETTINGS parameters (RFC 7540 Section 6.5.1).