Struct Request

Source
pub struct Request<P = PayloadStream> { /* private fields */ }
Expand description

Request

Implementations§

Source§

impl Request<PayloadStream>

Source

pub fn new() -> Request<PayloadStream>

Create new Request instance

Source§

impl<P> Request<P>

Source

pub fn with_payload(payload: Payload<P>) -> Request<P>

Create new Request instance

Source

pub fn replace_payload<P1>( self, payload: Payload<P1>, ) -> (Request<P1>, Payload<P>)

Create new Request instance

Source

pub fn payload(&mut self) -> &mut Payload<P>

Get request’s payload

Source

pub fn take_payload(&mut self) -> Payload<P>

Get request’s payload

Source

pub fn into_parts(self) -> (Message<RequestHead>, Payload<P>)

Split request into request head and payload

Source

pub fn head(&self) -> &RequestHead

Http message part of the request

Source

pub fn headers_mut(&mut self) -> &mut HeaderMap

Mutable reference to the message’s headers.

Source

pub fn uri(&self) -> &Uri

Request’s uri.

Source

pub fn uri_mut(&mut self) -> &mut Uri

Mutable reference to the request’s uri.

Source

pub fn method(&self) -> &Method

Read the Request method.

Source

pub fn version(&self) -> Version

Read the Request Version.

Source

pub fn path(&self) -> &str

The target path of this Request.

Source

pub fn upgrade(&self) -> bool

Check if request requires connection upgrade

Source

pub fn peer_addr(&self) -> Option<SocketAddr>

Peer socket address

Peer address is actual socket address, if proxy is used in front of scrappy http server, then peer address would be address of this proxy.

Trait Implementations§

Source§

impl<P> Debug for Request<P>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Message<RequestHead>> for Request<PayloadStream>

Source§

fn from(head: Message<RequestHead>) -> Self

Converts to this type from the input type.
Source§

impl<P> HttpMessage for Request<P>

Source§

fn extensions(&self) -> Ref<'_, Extensions>

Request extensions

Source§

fn extensions_mut(&self) -> RefMut<'_, Extensions>

Mutable reference to a the request’s extensions

Source§

type Stream = P

Type of message payload stream
Source§

fn headers(&self) -> &HeaderMap

Read the message headers.
Source§

fn take_payload(&mut self) -> Payload<P>

Message payload stream
Source§

fn content_type(&self) -> &str

Read the request content type. If request does not contain Content-Type header, empty str get returned.
Source§

fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>

Get content type encoding Read more
Source§

fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>

Convert the request content type to a known mime type.
Source§

fn chunked(&self) -> Result<bool, ParseError>

Check if request has chunked transfer encoding
Source§

fn cookies(&self) -> Result<Ref<'_, Vec<Cookie<'static>>>, CookieParseError>

Load request cookies.
Source§

fn cookie(&self, name: &str) -> Option<Cookie<'static>>

Return request cookie.

Auto Trait Implementations§

§

impl<P> Freeze for Request<P>
where P: Freeze,

§

impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>> !RefUnwindSafe for Request<P>

§

impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>> !Send for Request<P>

§

impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>> !Sync for Request<P>

§

impl<P> Unpin for Request<P>
where P: Unpin,

§

impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>> !UnwindSafe for Request<P>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,