Skip to main content

Request

Struct Request 

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

An HTTP request.

Implementations§

Source§

impl Request

Source

pub fn new() -> Request

Creates an empty request.

Source§

impl Request

Source

pub fn with_payload(payload: Payload) -> Request

Creates a request with the supplied payload.

Source

pub fn head(&self) -> &RequestHead

Returns the request head.

Source

pub fn uri(&self) -> &Url

Returns the request URI.

Source

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

Returns mutable access to the request URI.

Source

pub fn method(&self) -> &Method

Returns the request method.

Source

pub fn version(&self) -> Version

Returns the HTTP version.

Source

pub fn path(&self) -> &str

Returns the path component of the request URI.

Source

pub fn headers(&self) -> &HeaderMap

Returns the request headers.

Source

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

Returns mutable access to the request headers.

Source

pub fn upgrade(&self) -> bool

Returns whether this is an upgrade or CONNECT request.

Source

pub fn io(&self) -> Option<&IoRef>

Returns the I/O object for the current connection, when available.

Source

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

Returns the peer socket address.

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

Source

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

Returns mutable access to the request payload.

Source

pub fn take_payload(&mut self) -> Payload

Takes the request payload, leaving an empty payload behind.

Source

pub fn replace_payload(&mut self, payload: Payload) -> Payload

Replaces the request payload and returns the previous value.

Source

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

Returns the request extensions.

Source

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

Returns mutable access to the request extensions.

Trait Implementations§

Source§

impl Debug for Request

Source§

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

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

impl Default for Request

Source§

fn default() -> Request

Returns the “default value” for a type. Read more
Source§

impl HttpMessage for Request

Source§

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

Request extensions

Source§

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

Mutable reference to a the request’s extensions

Source§

fn message_headers(&self) -> &HeaderMap

Returns the message headers.
Source§

fn content_type(&self) -> &str

Returns the media type from the Content-Type header. Read more
Source§

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

Returns the character encoding declared by Content-Type. Read more
Source§

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

Parses the Content-Type header as a MIME type. Read more
Source§

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

Returns whether Transfer-Encoding contains chunked. Read more
Source§

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

Parses and caches cookies from the Cookie headers. Read more
Source§

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

Returns the first request cookie with the given name.
Source§

impl<St, F> Service<St, Request> for AppService<St, F>
where St: State, F: Service<St, WebRequest<()>, Res = WebResponse, Error = WebError<St, St::Error>>,

Source§

type Res = Response

Response produced by the service.
Source§

type Error = <F as Service<St, WebRequest>>::Error

Error produced while checking readiness or processing a request.
Source§

async fn ready(&self, ctx: Ctx<'_, Self, St>) -> Result<(), Self::Error>

Waits until the service is ready to process a request. Read more
Source§

async fn shutdown(&self, ctx: Ctx<'_, Self, St>)

Shuts down the service. Read more
Source§

async fn call( &self, req: Request, ctx: Ctx<'_, Self, St>, ) -> Result<Self::Res, F::Error>

Processes a request and asynchronously returns the response. Read more
Source§

fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
where Self: Sized, F: Fn(Self::Res) -> Res,

Maps this service’s output to a different type, returning a new service. Read more
Source§

fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
where Self: Sized, F: Fn(Self::Error) -> E,

Maps this service’s error to a different type, returning a new service. Read more
Source§

fn and_then<Next, F>(self, f: F) -> ServiceChain<AndThen<Self, Next>, St, Req>
where Self: Sized, Next: Service<St, Self::Res, Error = Self::Error>, F: IntoService<Next, St, Self::Res>,

Calls another service after this service completes successfully. Read more
Source§

fn pipeline(self, st: St) -> Pipeline<Req, Self::Res, Self::Error>
where Self: Sized + 'static, St: 'static, Req: 'static,

Wraps this service and its state in a Pipeline.

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