pub struct Request<'buf> {
pub body: Option<&'buf [u8]>,
pub method: &'buf str,
pub document: &'buf str,
pub query_raw: &'buf str,
pub protocol: &'buf str,
pub version: &'buf str,
pub header_raw_lines: Vec<&'buf str>,
pub peer_addr: Option<SocketAddr>,
/* private fields */
}
Expand description
Request contains the request representation that is serialised from the main HTTP request from the socket.
Fields§
§body: Option<&'buf [u8]>
§method: &'buf str
§document: &'buf str
§query_raw: &'buf str
§protocol: &'buf str
§version: &'buf str
§header_raw_lines: Vec<&'buf str>
§peer_addr: Option<SocketAddr>
Implementations§
Source§impl<'buf> Request<'buf>
impl<'buf> Request<'buf>
Sourcepub fn from_slice(buf: &'buf [u8]) -> Result<Self, RequestError<'buf>>
pub fn from_slice(buf: &'buf [u8]) -> Result<Self, RequestError<'buf>>
Construct a new request object using only a slice of u8
Sourcepub fn new(
buf: &'buf [u8],
peer_addr: Option<&SocketAddr>,
) -> Result<Self, RequestError<'buf>>
pub fn new( buf: &'buf [u8], peer_addr: Option<&SocketAddr>, ) -> Result<Self, RequestError<'buf>>
Construct a new request object, parsing the request buffer
pub fn host(&mut self) -> Option<&'buf str>
pub fn user_agent(&mut self) -> Option<&'buf str>
pub fn content_type(&mut self) -> Option<&'buf str>
pub fn content_length(&mut self) -> Option<usize>
Sourcepub fn header(&mut self, key: &str) -> Option<&'buf str>
pub fn header(&mut self, key: &str) -> Option<&'buf str>
looks up HTTP headers and returns headers are not parsed until they are needed
looks up cookies keys and returns its value cookies are not parsed until they are needed, will parse headers too.
Trait Implementations§
Auto Trait Implementations§
impl<'buf> Freeze for Request<'buf>
impl<'buf> RefUnwindSafe for Request<'buf>
impl<'buf> Send for Request<'buf>
impl<'buf> Sync for Request<'buf>
impl<'buf> Unpin for Request<'buf>
impl<'buf> UnwindSafe for Request<'buf>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more