pub struct HeaderMap { /* private fields */ }Implementations§
Source§impl HeaderMap
impl HeaderMap
pub fn new() -> HeaderMap
pub fn iter(&self) -> Iter<'_, (HeaderName, HeaderValue)>
pub fn iter_mut(&mut self) -> IterMut<'_, (HeaderName, HeaderValue)>
pub fn push<T, V>(&mut self, name: T, value: V) -> Option<HeaderValue>where
HeaderName: TryFrom<T>,
<HeaderName as TryFrom<T>>::Error: Into<WebError>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<WebError>,
Sourcepub fn insert<T, V>(&mut self, name: T, value: V) -> Option<HeaderValue>where
HeaderName: TryFrom<T>,
<HeaderName as TryFrom<T>>::Error: Into<WebError>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<WebError>,
pub fn insert<T, V>(&mut self, name: T, value: V) -> Option<HeaderValue>where
HeaderName: TryFrom<T>,
<HeaderName as TryFrom<T>>::Error: Into<WebError>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<WebError>,
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}pub fn remove<T: AsRef<[u8]>>(&mut self, name: &T) -> Option<HeaderValue>
pub fn clear(&mut self)
pub fn contains<T: AsRef<[u8]>>(&self, name: &T) -> bool
pub fn get_value<T: AsRef<[u8]>>(&self, name: &T) -> &HeaderValue
pub fn get_mut_value<'a, T: AsRef<[u8]>>( &'a mut self, name: &T, ) -> &'a mut HeaderValue
pub fn get_option_value<T: AsRef<[u8]>>(&self, name: &T) -> Option<&HeaderValue>
pub fn get_str_value<T: AsRef<[u8]>>(&self, name: &T) -> Option<String>
pub fn is_contains<T: AsRef<[u8]>>(&self, name: &T, value: &[u8]) -> bool
pub fn is_equal<T: AsRef<[u8]>>(&self, name: &T, value: &[u8]) -> bool
pub fn get_host(&self) -> Option<String>
pub fn get_referer(&self) -> Option<String>
pub fn get_user_agent(&self) -> Option<String>
pub fn get_body_len(&self) -> isize
Sourcepub fn is_keep_alive(&self) -> bool
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}pub fn is_chunked(&self) -> bool
pub fn get_upgrade_protocol(&self) -> Option<String>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn system_insert(&mut self, key: String, value: String)
pub fn system_get<Q>(&self, key: &Q) -> Option<&String>
pub fn encode<B: Bt + BtMut>(&self, buffer: &mut B) -> WebResult<usize>
Trait Implementations§
Source§impl IntoIterator for HeaderMap
impl IntoIterator for HeaderMap
Source§type Item = (HeaderName, HeaderValue)
type Item = (HeaderName, HeaderValue)
The type of the elements being iterated over.
Source§type IntoIter = IntoIter<(HeaderName, HeaderValue)>
type IntoIter = IntoIter<(HeaderName, HeaderValue)>
Which kind of iterator are we turning this into?
impl Eq for HeaderMap
impl StructuralPartialEq for HeaderMap
Auto Trait Implementations§
impl Freeze for HeaderMap
impl RefUnwindSafe for HeaderMap
impl Send for HeaderMap
impl Sync for HeaderMap
impl Unpin for HeaderMap
impl UnwindSafe for HeaderMap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.