Handle padding & stream priority when parsing headers frame

This commit is contained in:
Carl Lerche
2017-08-10 13:55:36 -07:00
parent e7c07b0b12
commit 50e0ad2f2a
4 changed files with 54 additions and 9 deletions

View File

@@ -9,11 +9,13 @@ const STREAM_ID_MASK: u32 = 1 << 31;
impl StreamId {
/// Parse the stream ID
#[inline]
pub fn parse(buf: &[u8]) -> StreamId {
pub fn parse(buf: &[u8]) -> (StreamId, bool) {
let unpacked = BigEndian::read_u32(buf);
let flag = unpacked & STREAM_ID_MASK == STREAM_ID_MASK;
// Now clear the most significant bit, as that is reserved and MUST be
// ignored when received.
StreamId(unpacked & !STREAM_ID_MASK)
(StreamId(unpacked & !STREAM_ID_MASK), flag)
}
pub fn is_client_initiated(&self) -> bool {