pub struct Request<'a, 'headers> {
pub method: Method,
pub path: &'a str,
pub headers: &'headers [Header<'a>],
pub body: &'a [u8],
}Expand description
A parsed HTTP request
Fields§
§method: MethodThe HTTP request method. Either Method::Get, Method::Post, or Method::Put
path: &'a strThe target URL for the request
headers: &'headers [Header<'a>]The HTTP request headers
body: &'a [u8]The body of the request or an empty slice if there is no body
Implementations§
Source§impl<'a, 'headers> Request<'a, 'headers>
impl<'a, 'headers> Request<'a, 'headers>
Sourcepub fn new(
method: Method,
path: &'a str,
headers: &'headers [Header<'a>],
body: &'a [u8],
) -> Self
pub fn new( method: Method, path: &'a str, headers: &'headers [Header<'a>], body: &'a [u8], ) -> Self
Construct a new Response from its parts
Use an empty &str to create a Respose with no body
Sourcepub fn as_bytes(&self) -> Vec<u8> ⓘ
pub fn as_bytes(&self) -> Vec<u8> ⓘ
The byte representation of the Request transmittible over wire
Sourcepub fn parse(
slice: &'a [u8],
headers_buf: &'headers mut [Header<'a>],
) -> Result<Request<'a, 'headers>>
pub fn parse( slice: &'a [u8], headers_buf: &'headers mut [Header<'a>], ) -> Result<Request<'a, 'headers>>
Parses the bytes of an HTTP request into a Request
It parses headers into the header_buf you pass, if there is more headers than the length of the buffer you pass, an Err(Error::TooManyHeaders) is returned
Trait Implementations§
impl<'a, 'headers> Eq for Request<'a, 'headers>
impl<'a, 'headers> StructuralPartialEq for Request<'a, 'headers>
Auto Trait Implementations§
impl<'a, 'headers> Freeze for Request<'a, 'headers>
impl<'a, 'headers> RefUnwindSafe for Request<'a, 'headers>
impl<'a, 'headers> Send for Request<'a, 'headers>
impl<'a, 'headers> Sync for Request<'a, 'headers>
impl<'a, 'headers> Unpin for Request<'a, 'headers>
impl<'a, 'headers> UnwindSafe for Request<'a, 'headers>
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