Skip to main content

Request

Struct Request 

Source
pub struct Request { /* private fields */ }
Expand description

An HTTP request with its body fully received.

A request shares the connection’s receive buffer instead of copying out of it, so creating one allocates nothing. It can be kept for as long as needed; the connection only reuses the buffer once the request has been dropped.

Implementations§

Source§

impl Request

Source

pub fn method(&self) -> &str

The request method, e.g. GET. Case-sensitive, as sent.

Source

pub fn target(&self) -> &str

The request target exactly as sent, e.g. /search?q=rust.

Source

pub fn path(&self) -> &str

The path part of the target, without the query string. For a target in absolute form (http://host/path), the scheme and host are left out.

Source

pub fn query(&self) -> Option<&str>

The query string, without the leading ?.

Source

pub fn version_minor(&self) -> u8

1 for HTTP/1.1, 0 for HTTP/1.0.

Source

pub fn headers(&self) -> impl Iterator<Item = (&str, &[u8])>

All header fields in the order they were sent, values trimmed.

Source

pub fn header(&self, name: &str) -> Option<&[u8]>

The first value of the header name (case-insensitive).

Source

pub fn header_str(&self, name: &str) -> Option<&str>

Like header, for values that are valid UTF-8.

Source

pub fn body(&self) -> &[u8] ⓘ

The request body. Empty if the request has none.

Trait Implementations§

Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.