Wire in trailers (#34)

Add send and receive trailer support.
This commit is contained in:
Carl Lerche
2017-08-25 10:20:47 -07:00
committed by GitHub
parent c0433e8831
commit 11d5f95236
12 changed files with 365 additions and 25 deletions

View File

@@ -98,6 +98,7 @@ const ALL: u8 = END_STREAM
// ===== impl Headers =====
impl Headers {
/// Create a new HEADERS frame
pub fn new(stream_id: StreamId, pseudo: Pseudo, fields: HeaderMap) -> Self {
Headers {
stream_id: stream_id,
@@ -108,6 +109,19 @@ impl Headers {
}
}
pub fn trailers(stream_id: StreamId, fields: HeaderMap) -> Self {
let mut flags = HeadersFlag::default();
flags.set_end_stream();
Headers {
stream_id,
stream_dep: None,
fields: fields,
pseudo: Pseudo::default(),
flags: flags,
}
}
/// Loads the header frame but doesn't actually do HPACK decoding.
///
/// HPACK decoding is done in the `load_hpack` step.
@@ -290,6 +304,10 @@ impl Headers {
Ok(request)
}
pub fn into_fields(self) -> HeaderMap {
self.fields
}
pub fn encode(self, encoder: &mut hpack::Encoder, dst: &mut BytesMut)
-> Option<Continuation>
{