pub struct HpackEncoder { /* private fields */ }Expand description
HPACK encoder with custom pseudo-header ordering.
Implementations§
Source§impl HpackEncoder
impl HpackEncoder
Sourcepub fn new(pseudo_order: PseudoHeaderOrder) -> Self
pub fn new(pseudo_order: PseudoHeaderOrder) -> Self
Create a new encoder with the specified pseudo-header order.
Sourcepub fn set_max_table_size(&mut self, size: usize)
pub fn set_max_table_size(&mut self, size: usize)
Set the dynamic table size.
Sourcepub fn encode_request(
&mut self,
method: &str,
scheme: &str,
authority: &str,
path: &str,
headers: impl Into<Headers>,
) -> Bytes
pub fn encode_request( &mut self, method: &str, scheme: &str, authority: &str, path: &str, headers: impl Into<Headers>, ) -> Bytes
Encode headers for an HTTP/2 request.
Pseudo-headers are ordered according to the configured order. Regular headers follow in the order provided.
Sourcepub fn encode_extended_connect_websocket(
&mut self,
authority: &str,
scheme: &str,
path: &str,
headers: impl Into<Headers>,
) -> Result<Bytes, String>
pub fn encode_extended_connect_websocket( &mut self, authority: &str, scheme: &str, path: &str, headers: impl Into<Headers>, ) -> Result<Bytes, String>
Encode RFC 8441 Extended CONNECT headers for WebSocket over HTTP/2.
The pseudo-header order is deterministic and spec-compliant for RFC 8441; it is not claimed to be Chrome-exact.
Sourcepub fn chunk_encoded(
encoded: Bytes,
max_frame_size: usize,
) -> (Bytes, Vec<Bytes>)
pub fn chunk_encoded( encoded: Bytes, max_frame_size: usize, ) -> (Bytes, Vec<Bytes>)
Split an encoded header block into chunks if it exceeds max_frame_size. Returns (first_chunk, remaining_chunks).
This is used when header blocks exceed MAX_FRAME_SIZE and must be split across HEADERS + CONTINUATION frames per RFC 9113 Section 6.10.
Use this after calling encode_request() to chunk the result if needed.