Struct actix_http::Request

source ·
pub struct Request<P = BoxedPayloadStream> { /* private fields */ }
Expand description

An HTTP request.

Implementations§

source§

impl Request<BoxedPayloadStream>

source

pub fn new() -> Request<BoxedPayloadStream>

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 the directly connected peer’s socket address. If a proxy is used in front of the Actix Web server, then it would be address of this proxy.

Will only return None when called in unit tests unless set manually.

source

pub fn conn_data<T: 'static>(&self) -> Option<&T>

Returns a reference a piece of connection data set in an on-connect callback.

let opt_t = req.conn_data::<PeerCertificate>();
source

pub fn take_conn_data(&mut self) -> Option<Rc<Extensions>>

Returns the connection-level data/extensions container if an on-connect callback was registered, leaving an empty one in its place.

source

pub fn take_req_data(&mut self) -> Extensions

Returns the request-local data/extensions container, leaving an empty one in its place.

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<BoxedPayloadStream>

source§

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

Converts to this type from the input type.
source§

impl<P> HttpMessage for Request<P>

§

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 extensions(&self) -> Ref<'_, Extensions>

Returns a reference to the request-local data/extensions container.
source§

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

Returns a mutable reference to the request-local data/extensions container.
source§

fn content_type(&self) -> &str

Read the request content type. If request did not contain a Content-Type header, an empty string is 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§

impl Service<Request> for ExpectHandler

§

type Response = Request

Responses given by the service.
§

type Error = Error

Errors produced by the service when polling readiness or executing call.
§

type Future = Ready<Result<<ExpectHandler as Service<Request>>::Response, <ExpectHandler as Service<Request>>::Error>>

The future response value.
source§

fn poll_ready(&self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Ready when the service is able to process requests. Read more
source§

fn call(&self, req: Request) -> Self::Future

Process the request and return the response asynchronously. Read more
source§

impl ServiceFactory<Request> for ExpectHandler

§

type Response = Request

Responses given by the created services.
§

type Error = Error

Errors produced by the created services.
§

type Config = ()

Service factory configuration.
§

type Service = ExpectHandler

The kind of Service created by this factory.
§

type InitError = Error

Errors potentially raised while building a service.
§

type Future = Ready<Result<<ExpectHandler as ServiceFactory<Request>>::Service, <ExpectHandler as ServiceFactory<Request>>::InitError>>

The future of the Service instance.g
source§

fn new_service(&self, _: Self::Config) -> Self::Future

Create and return a new service asynchronously.

Auto Trait Implementations§

§

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

§

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.

§

impl<T> Instrument for T

§

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

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

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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