[−][src]Struct http_str::Request
Fields
entire_req: &'a str
method: &'a str
uri: &'a str
query: &'a str
version: &'a str
body: &'a str
headers_map: BTreeMap<&'a str, Vec<&'a str>>
Methods
impl<'a> Request<'a>
[src]
pub fn new(bytes: &'a [u8]) -> Pin<Box<Self>>
[src]
Creates a new Request from a slice of bytes utf8 encoded forming a http request.
It is up to the caller that these bytes are valid utf8.
Panics
This function will panic if the bytes contain no space character(32).
Examples
use std::str::from_utf8_unchecked; use http_str::Request; let req = b"GET /index.html?myquery HTTP/1.1\r\nHost: www.example.com\r\nHello world!"; let request = Request::new(req); assert_eq!(request.entire_req, unsafe { from_utf8_unchecked(req) }); assert_eq!(request.method, "GET"); // all the other fields refer to `entire_req` assert_eq!(request.uri, "/index.html"); assert_eq!(request.query, "myquery"); assert_eq!(request.version, "HTTP/1.1"); assert_eq!(request.headers_map["Host"], vec!["www.example.com"]); assert_eq!(request.body, "Hello world!");
pub fn with_method_len(bytes: &'a [u8], method_len: usize) -> Pin<Box<Self>>
[src]
Creates a new Request from a slice of bytes utf8 encoded forming a http request and the length of the http method.
This will not produce the correct result if method_len is incorrect but takes less time than the normal constructor, use it when you do know the method of the request.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Request<'a>
impl<'a> Send for Request<'a>
impl<'a> Sync for Request<'a>
impl<'a> !Unpin for Request<'a>
impl<'a> UnwindSafe for Request<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,