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)
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
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");
}
}
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)
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
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");
}
}
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)