Struct webparse::http::HeaderMap

source ·
pub struct HeaderMap { /* private fields */ }

Implementations§

source§

impl HeaderMap

source

pub fn new() -> HeaderMap

source

pub fn iter(&self) -> Iter<'_, (HeaderName, HeaderValue)>

source

pub fn iter_mut(&mut self) -> IterMut<'_, (HeaderName, HeaderValue)>

source

pub fn push<T, V>(&mut self, name: T, value: V) -> Option<HeaderValue>

source

pub fn insert<T, V>(&mut self, name: T, value: V) -> Option<HeaderValue>

Examples found in repository?
examples/demo.rs (line 128)
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
fn debug_request_parse() {
    let mut request = Request::new();
    request.headers_mut().insert("Connection", "ok");
    let _xx = request.headers().is_keep_alive();
    return;
    // // let value = url::Url::parse("/path");
    let _bytes = [80, 79, 83, 84, 32, 47, 112, 111, 115, 116, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72, 111, 115, 116, 58, 32, 49, 57, 50, 46, 49, 54, 56, 46, 49, 55, 57, 46, 49, 51, 51, 58, 56, 48, 56, 48, 13, 10, 85, 115, 101, 114, 45, 65, 103, 101, 110, 116, 58, 32, 99, 117, 114, 108, 47, 55, 46, 55, 52, 46, 48, 13, 10, 65, 99, 99, 101, 112, 116, 58, 32, 42, 47, 42, 13, 10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 85, 112, 103, 114, 97, 100, 101, 44, 32, 72, 84, 84, 80, 50, 45, 83, 101, 116, 116, 105, 110, 103, 115, 13, 10, 85, 112, 103, 114, 97, 100, 101, 58, 32, 104, 50, 99, 13, 10, 72, 84, 84, 80, 50, 45, 83, 101, 116, 116, 105, 110, 103, 115, 58, 32, 65, 65, 77, 65, 65, 65, 66, 107, 65, 65, 81, 67, 65, 65, 65, 65, 65, 65, 73, 65, 65, 65, 65, 65, 13, 10, 99, 117, 115, 116, 111, 109, 45, 107, 101, 121, 58, 99, 117, 115, 116, 111, 109, 45, 118, 97, 108, 117, 101, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 50, 49, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 120, 45, 119, 119, 119, 45, 102, 111, 114, 109, 45, 117, 114, 108, 101, 110, 99, 111, 100, 101, 100, 13, 10, 13, 10, 97, 97, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48];
    let _result = request.parse(b"GET //:///// HTTP/1.1\r\nHost: Upgrade, HTTP2-Settings \r\n\r\naaa");
    // let _result = request.parse(&bytes);

    println!("result = {:?}", request);
    println!("is_partial = {}", request.is_partial());
    println!("body len = {}", request.get_body_len());
    println!("host len = {:?}", request.get_host());
    println!("host len = {:?}", request.get_connect_url());
    println!(
        "http data = {}",
        String::from_utf8_lossy(&request.http1_data().unwrap())
    );
    assert_eq!(
        String::from_utf8_lossy(&request.http1_data().unwrap()).as_bytes(),
        b"GET //:///// HTTP/1.1\r\nHost: \r\n\r\n"
    );
    let x = &request.headers()["Host"];
    if x == &"foo" {
        println!("111");
    }
    if &"foo" == x {
        println!("111");
    }
}
source

pub fn remove<T: AsRef<[u8]>>(&mut self, name: &T) -> Option<HeaderValue>

source

pub fn clear(&mut self)

source

pub fn contains<T: AsRef<[u8]>>(&self, name: &T) -> bool

source

pub fn get_value<T: AsRef<[u8]>>(&self, name: &T) -> &HeaderValue

source

pub fn get_mut_value<'a, T: AsRef<[u8]>>( &'a mut self, name: &T ) -> &'a mut HeaderValue

source

pub fn get_option_value<T: AsRef<[u8]>>(&self, name: &T) -> Option<&HeaderValue>

source

pub fn get_str_value<T: AsRef<[u8]>>(&self, name: &T) -> Option<String>

source

pub fn is_contains<T: AsRef<[u8]>>(&self, name: &T, value: &[u8]) -> bool

source

pub fn is_equal<T: AsRef<[u8]>>(&self, name: &T, value: &[u8]) -> bool

source

pub fn get_host(&self) -> Option<String>

source

pub fn get_referer(&self) -> Option<String>

source

pub fn get_user_agent(&self) -> Option<String>

source

pub fn get_body_len(&self) -> isize

source

pub fn is_keep_alive(&self) -> bool

Examples found in repository?
examples/demo.rs (line 129)
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
fn debug_request_parse() {
    let mut request = Request::new();
    request.headers_mut().insert("Connection", "ok");
    let _xx = request.headers().is_keep_alive();
    return;
    // // let value = url::Url::parse("/path");
    let _bytes = [80, 79, 83, 84, 32, 47, 112, 111, 115, 116, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72, 111, 115, 116, 58, 32, 49, 57, 50, 46, 49, 54, 56, 46, 49, 55, 57, 46, 49, 51, 51, 58, 56, 48, 56, 48, 13, 10, 85, 115, 101, 114, 45, 65, 103, 101, 110, 116, 58, 32, 99, 117, 114, 108, 47, 55, 46, 55, 52, 46, 48, 13, 10, 65, 99, 99, 101, 112, 116, 58, 32, 42, 47, 42, 13, 10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 85, 112, 103, 114, 97, 100, 101, 44, 32, 72, 84, 84, 80, 50, 45, 83, 101, 116, 116, 105, 110, 103, 115, 13, 10, 85, 112, 103, 114, 97, 100, 101, 58, 32, 104, 50, 99, 13, 10, 72, 84, 84, 80, 50, 45, 83, 101, 116, 116, 105, 110, 103, 115, 58, 32, 65, 65, 77, 65, 65, 65, 66, 107, 65, 65, 81, 67, 65, 65, 65, 65, 65, 65, 73, 65, 65, 65, 65, 65, 13, 10, 99, 117, 115, 116, 111, 109, 45, 107, 101, 121, 58, 99, 117, 115, 116, 111, 109, 45, 118, 97, 108, 117, 101, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 50, 49, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 120, 45, 119, 119, 119, 45, 102, 111, 114, 109, 45, 117, 114, 108, 101, 110, 99, 111, 100, 101, 100, 13, 10, 13, 10, 97, 97, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48];
    let _result = request.parse(b"GET //:///// HTTP/1.1\r\nHost: Upgrade, HTTP2-Settings \r\n\r\naaa");
    // let _result = request.parse(&bytes);

    println!("result = {:?}", request);
    println!("is_partial = {}", request.is_partial());
    println!("body len = {}", request.get_body_len());
    println!("host len = {:?}", request.get_host());
    println!("host len = {:?}", request.get_connect_url());
    println!(
        "http data = {}",
        String::from_utf8_lossy(&request.http1_data().unwrap())
    );
    assert_eq!(
        String::from_utf8_lossy(&request.http1_data().unwrap()).as_bytes(),
        b"GET //:///// HTTP/1.1\r\nHost: \r\n\r\n"
    );
    let x = &request.headers()["Host"];
    if x == &"foo" {
        println!("111");
    }
    if &"foo" == x {
        println!("111");
    }
}
source

pub fn is_chunked(&self) -> bool

source

pub fn get_upgrade_protocol(&self) -> Option<String>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn system_insert(&mut self, key: String, value: String)

source

pub fn system_get<Q>(&self, key: &Q) -> Option<&String>
where String: Borrow<Q>, Q: Hash + Eq + ?Sized,

source

pub fn encode<B: Buf + BufMut>(&self, buffer: &mut B) -> WebResult<usize>

Trait Implementations§

source§

impl Clone for HeaderMap

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HeaderMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for HeaderMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Index<&'static str> for HeaderMap

§

type Output = HeaderValue

The returned type after indexing.
source§

fn index(&self, index: &'static str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<&'static str> for HeaderMap

source§

fn index_mut(&mut self, index: &'static str) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl IntoIterator for HeaderMap

§

type Item = (HeaderName, HeaderValue)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<(HeaderName, HeaderValue)>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for HeaderMap

source§

fn eq(&self, other: &HeaderMap) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for HeaderMap

source§

impl StructuralPartialEq for HeaderMap

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.