Struct 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 132)
130fn debug_request_parse() {
131    let mut request = Request::new();
132    request.headers_mut().insert("Connection", "ok");
133    let _xx = request.headers().is_keep_alive();
134    return;
135    // // let value = url::Url::parse("/path");
136    let _bytes = [
137        80, 79, 83, 84, 32, 47, 112, 111, 115, 116, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72,
138        111, 115, 116, 58, 32, 49, 57, 50, 46, 49, 54, 56, 46, 49, 55, 57, 46, 49, 51, 51, 58, 56,
139        48, 56, 48, 13, 10, 85, 115, 101, 114, 45, 65, 103, 101, 110, 116, 58, 32, 99, 117, 114,
140        108, 47, 55, 46, 55, 52, 46, 48, 13, 10, 65, 99, 99, 101, 112, 116, 58, 32, 42, 47, 42, 13,
141        10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 85, 112, 103, 114, 97, 100,
142        101, 44, 32, 72, 84, 84, 80, 50, 45, 83, 101, 116, 116, 105, 110, 103, 115, 13, 10, 85,
143        112, 103, 114, 97, 100, 101, 58, 32, 104, 50, 99, 13, 10, 72, 84, 84, 80, 50, 45, 83, 101,
144        116, 116, 105, 110, 103, 115, 58, 32, 65, 65, 77, 65, 65, 65, 66, 107, 65, 65, 81, 67, 65,
145        65, 65, 65, 65, 65, 73, 65, 65, 65, 65, 65, 13, 10, 99, 117, 115, 116, 111, 109, 45, 107,
146        101, 121, 58, 99, 117, 115, 116, 111, 109, 45, 118, 97, 108, 117, 101, 13, 10, 67, 111,
147        110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 50, 49, 13, 10, 67, 111,
148        110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 97, 112, 112, 108, 105, 99, 97,
149        116, 105, 111, 110, 47, 120, 45, 119, 119, 119, 45, 102, 111, 114, 109, 45, 117, 114, 108,
150        101, 110, 99, 111, 100, 101, 100, 13, 10, 13, 10, 97, 97, 48, 48, 48, 48, 48, 48, 48, 48,
151        48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
152    ];
153    let _result =
154        request.parse(b"GET //:///// HTTP/1.1\r\nHost: Upgrade, HTTP2-Settings \r\n\r\naaa");
155    // let _result = request.parse(&bytes);
156
157    println!("result = {:?}", request);
158    println!("is_partial = {}", request.is_partial());
159    println!("body len = {}", request.get_body_len());
160    println!("host len = {:?}", request.get_host());
161    println!("host len = {:?}", request.get_connect_url());
162    println!(
163        "http data = {}",
164        String::from_utf8_lossy(&request.http1_data().unwrap())
165    );
166    assert_eq!(
167        String::from_utf8_lossy(&request.http1_data().unwrap()).as_bytes(),
168        b"GET //:///// HTTP/1.1\r\nHost: \r\n\r\n"
169    );
170    let x = &request.headers()["Host"];
171    if x == &"foo" {
172        println!("111");
173    }
174    if &"foo" == x {
175        println!("111");
176    }
177}
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 133)
130fn debug_request_parse() {
131    let mut request = Request::new();
132    request.headers_mut().insert("Connection", "ok");
133    let _xx = request.headers().is_keep_alive();
134    return;
135    // // let value = url::Url::parse("/path");
136    let _bytes = [
137        80, 79, 83, 84, 32, 47, 112, 111, 115, 116, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72,
138        111, 115, 116, 58, 32, 49, 57, 50, 46, 49, 54, 56, 46, 49, 55, 57, 46, 49, 51, 51, 58, 56,
139        48, 56, 48, 13, 10, 85, 115, 101, 114, 45, 65, 103, 101, 110, 116, 58, 32, 99, 117, 114,
140        108, 47, 55, 46, 55, 52, 46, 48, 13, 10, 65, 99, 99, 101, 112, 116, 58, 32, 42, 47, 42, 13,
141        10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 85, 112, 103, 114, 97, 100,
142        101, 44, 32, 72, 84, 84, 80, 50, 45, 83, 101, 116, 116, 105, 110, 103, 115, 13, 10, 85,
143        112, 103, 114, 97, 100, 101, 58, 32, 104, 50, 99, 13, 10, 72, 84, 84, 80, 50, 45, 83, 101,
144        116, 116, 105, 110, 103, 115, 58, 32, 65, 65, 77, 65, 65, 65, 66, 107, 65, 65, 81, 67, 65,
145        65, 65, 65, 65, 65, 73, 65, 65, 65, 65, 65, 13, 10, 99, 117, 115, 116, 111, 109, 45, 107,
146        101, 121, 58, 99, 117, 115, 116, 111, 109, 45, 118, 97, 108, 117, 101, 13, 10, 67, 111,
147        110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 50, 49, 13, 10, 67, 111,
148        110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 97, 112, 112, 108, 105, 99, 97,
149        116, 105, 111, 110, 47, 120, 45, 119, 119, 119, 45, 102, 111, 114, 109, 45, 117, 114, 108,
150        101, 110, 99, 111, 100, 101, 100, 13, 10, 13, 10, 97, 97, 48, 48, 48, 48, 48, 48, 48, 48,
151        48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
152    ];
153    let _result =
154        request.parse(b"GET //:///// HTTP/1.1\r\nHost: Upgrade, HTTP2-Settings \r\n\r\naaa");
155    // let _result = request.parse(&bytes);
156
157    println!("result = {:?}", request);
158    println!("is_partial = {}", request.is_partial());
159    println!("body len = {}", request.get_body_len());
160    println!("host len = {:?}", request.get_host());
161    println!("host len = {:?}", request.get_connect_url());
162    println!(
163        "http data = {}",
164        String::from_utf8_lossy(&request.http1_data().unwrap())
165    );
166    assert_eq!(
167        String::from_utf8_lossy(&request.http1_data().unwrap()).as_bytes(),
168        b"GET //:///// HTTP/1.1\r\nHost: \r\n\r\n"
169    );
170    let x = &request.headers()["Host"];
171    if x == &"foo" {
172        println!("111");
173    }
174    if &"foo" == x {
175        println!("111");
176    }
177}
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: Bt + BtMut>(&self, buffer: &mut B) -> WebResult<usize>

Trait Implementations§

Source§

impl Clone for HeaderMap

Source§

fn clone(&self) -> Self

Returns a duplicate 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

Source§

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

Source§

type Item = (HeaderName, HeaderValue)

The type of the elements being iterated over.
Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

Source§

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§

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>,

Source§

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>,

Source§

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.