[−][src]Module hpack::encoder
Implements all functionality related to encoding header blocks using HPACK.
Clients should use the Encoder
struct as the API for performing HPACK
encoding.
Examples
Encodes a header using a literal encoding.
use hpack::Encoder; let mut encoder = Encoder::new(); let headers = vec![ (&b"custom-key"[..], &b"custom-value"[..]), ]; // First encoding... let result = encoder.encode(headers); // The result is a literal encoding of the header name and value, with an // initial byte representing the type of the encoding // (incremental indexing). assert_eq!( vec![0x40, 10, b'c', b'u', b's', b't', b'o', b'm', b'-', b'k', b'e', b'y', 12, b'c', b'u', b's', b't', b'o', b'm', b'-', b'v', b'a', b'l', b'u', b'e'], result);
Encodes some pseudo-headers that are already found in the static table.
use hpack::Encoder; let mut encoder = Encoder::new(); let headers = vec![ (&b":method"[..], &b"GET"[..]), (&b":path"[..], &b"/"[..]), ]; // The headers are encoded by providing their index (with a bit flag // indicating that the indexed representation is used). assert_eq!(encoder.encode(headers), vec![2 | 0x80, 4 | 0x80]);
Structs
Encoder | Represents an HPACK encoder. Allows clients to encode arbitrary header sets and tracks the encoding context. That is, encoding subsequent header sets will use the context built by previous encode calls. |
Functions
encode_integer | Encode an integer to the representation defined by HPACK. |
encode_integer_into | Encode an integer to the representation defined by HPACK, writing it into the provider
|