This commit is contained in:
Carl Lerche
2017-03-12 22:33:45 -07:00
parent fb09a0e12c
commit 490ae8c05d
4 changed files with 89 additions and 17 deletions

40
src/hpack/entry.rs Normal file
View File

@@ -0,0 +1,40 @@
use tower::http::{HeaderName, Method, StatusCode, Str};
/// HPack table entry
pub enum Entry {
Header {
name: HeaderName,
value: Str,
},
Authority(Str),
Method(Method),
Scheme(Str),
Path(Str),
Status(StatusCode),
}
impl Entry {
pub fn len(&self) -> usize {
match *self {
Entry::Header { ref name, ref value } => {
let n: &str = name.as_ref();
32 + n.len() + value.len()
}
Entry::Authority(ref v) => {
32 + 10 + v.len()
}
Entry::Method(ref v) => {
32 + 7 + v.as_ref().len()
}
Entry::Scheme(ref v) => {
32 + 7 + v.len()
}
Entry::Path(ref v) => {
32 + 5 + v.len()
}
Entry::Status(ref v) => {
32 + 7 + 3
}
}
}
}