Skip to main content

Request

Struct Request 

Source
pub struct Request<'a, const HEADER_SIZE_MAX: usize = 4096> {
    pub header: Data,
    pub method: Data,
    pub target: Data,
    pub version: Data,
    pub fields: Vec<(Data, Data)>,
    pub stream: &'a mut Source,
}
Expand description

A HTTP request

Fields§

§header: Data

The raw header bytes

§method: Data

The method part within the request line

§target: Data

The target part within the request line

§version: Data

The version part within the request line

§fields: Vec<(Data, Data)>

The key/value fields within the header

§stream: &'a mut Source

The connection stream

Implementations§

Source§

impl<'a, const HEADER_SIZE_MAX: usize> Request<'a, HEADER_SIZE_MAX>

Source

pub fn from_stream(stream: &'a mut Source) -> Result<Option<Self>, Error>

Reads a HTTP request from a readable stream

Source§

impl<'a, const HEADER_SIZE_MAX: usize> Request<'a, HEADER_SIZE_MAX>

Source

pub fn target_path(&self) -> Option<&Path>

Gets the request target as path

§Important

On non-unix platforms, this function uses a str as intermediate representation, so the path must be valid UTF-8. If this might be a problem, you should use the raw target field directly.

Source

pub fn field<N>(&self, name: N) -> Option<&Data>
where N: AsRef<[u8]>,

Gets the field with the given name (performs an ASCII-case-insensitve comparison)

Source

pub fn content_length(&self) -> Result<Option<u64>, Error>

The request content length field if any

Source

pub fn read_body_data( &mut self, content_length_max: u64, ) -> Result<Option<Data>, Error>

Reads the request body into memory if a content-length header is set and transfer-encoding is not chunked; returns None otherwise

Trait Implementations§

Source§

impl<'a, const HEADER_SIZE_MAX: usize> Debug for Request<'a, HEADER_SIZE_MAX>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, const HEADER_SIZE_MAX: usize> Freeze for Request<'a, HEADER_SIZE_MAX>

§

impl<'a, const HEADER_SIZE_MAX: usize = 4096> !RefUnwindSafe for Request<'a, HEADER_SIZE_MAX>

§

impl<'a, const HEADER_SIZE_MAX: usize> Send for Request<'a, HEADER_SIZE_MAX>

§

impl<'a, const HEADER_SIZE_MAX: usize> Sync for Request<'a, HEADER_SIZE_MAX>

§

impl<'a, const HEADER_SIZE_MAX: usize> Unpin for Request<'a, HEADER_SIZE_MAX>

§

impl<'a, const HEADER_SIZE_MAX: usize> UnsafeUnpin for Request<'a, HEADER_SIZE_MAX>

§

impl<'a, const HEADER_SIZE_MAX: usize = 4096> !UnwindSafe for Request<'a, HEADER_SIZE_MAX>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.