pub struct Decoder {
pub index: Arc<RwLock<HeaderIndex>>,
}Fields§
§index: Arc<RwLock<HeaderIndex>>Implementations§
source§impl Decoder
impl Decoder
sourcepub fn new() -> Decoder
pub fn new() -> Decoder
Examples found in repository?
examples/http2.rs (line 5)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn parse_header() {
let mut decoder = Decoder::new();
// C.4.1
let buf = Helper::hex_to_vec("8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff");
let buf_len = buf.len();
let mut header = Headers::empty();
let size = header.parse(BinaryMut::from(buf), &mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();
assert!(size == buf_len);
assert!(header.method() == &Some(Method::Get));
assert!(header.path() == &Some("/".to_string()));
assert!(header.scheme() == &Some(Scheme::Http));
assert!(header.authority() == &Some("www.example.com".to_string()));
// C.4.2
let buf = Helper::hex_to_vec("8286 84be 5886 a8eb 1064 9cbf");
let buf_len = buf.len();
let mut header = Headers::empty();
let size = header.parse(BinaryMut::from(buf), &mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();
assert!(size == buf_len);
assert!(header.method() == &Some(Method::Get));
assert!(header.path() == &Some("/".to_string()));
assert!(header.scheme() == &Some(Scheme::Http));
assert!(header.authority() == &Some("www.example.com".to_string()));
assert!(header.fields()["cache-control"] == "no-cache");
// C.4.3
let buf = Helper::hex_to_vec("8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf ");
let buf_len = buf.len();
let mut header = Headers::empty();
let size = header.parse(BinaryMut::from(buf), &mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();
assert!(size == buf_len);
assert!(header.method() == &Some(Method::Get));
assert!(header.path() == &Some("/index.html".to_string()));
assert!(header.scheme() == &Some(Scheme::Https));
assert!(header.authority() == &Some("www.example.com".to_string()));
assert!(header.fields()["custom-key"] == "custom-value");
}pub fn new_index(index: Arc<RwLock<HeaderIndex>>) -> Decoder
pub fn decode<B: Buf>( &mut self, buf: &mut B ) -> WebResult<Vec<(HeaderName, HeaderValue)>>
pub fn decode_with_cb<F, B: Buf>(&mut self, buf: &mut B, cb: F) -> WebResult<()>
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnwindSafe for Decoder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more