Struct actix_http::Request
source · [−]pub struct Request<P = PayloadStream> { /* private fields */ }
Expand description
An HTTP request.
Implementations
sourceimpl Request<PayloadStream>
impl Request<PayloadStream>
sourcepub fn new() -> Request<PayloadStream>
pub fn new() -> Request<PayloadStream>
Create new Request instance
sourceimpl<P> Request<P>
impl<P> Request<P>
sourcepub fn with_payload(payload: Payload<P>) -> Request<P>
pub fn with_payload(payload: Payload<P>) -> Request<P>
Create new Request instance
sourcepub fn replace_payload<P1>(
self,
payload: Payload<P1>
) -> (Request<P1>, Payload<P>)
pub fn replace_payload<P1>(
self,
payload: Payload<P1>
) -> (Request<P1>, Payload<P>)
Create new Request instance
sourcepub fn take_payload(&mut self) -> Payload<P>
pub fn take_payload(&mut self) -> Payload<P>
Get request’s payload
sourcepub fn into_parts(self) -> (Message<RequestHead>, Payload<P>)
pub fn into_parts(self) -> (Message<RequestHead>, Payload<P>)
Split request into request head and payload
sourcepub fn head(&self) -> &RequestHead
pub fn head(&self) -> &RequestHead
Http message part of the request
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Mutable reference to the message’s headers.
sourcepub fn peer_addr(&self) -> Option<SocketAddr>
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.
sourcepub fn conn_data<T: 'static>(&self) -> Option<&T>
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>();
sourcepub fn take_conn_data(&mut self) -> Option<Rc<Extensions>>
pub fn take_conn_data(&mut self) -> Option<Rc<Extensions>>
Returns the connection data container if an on-connect callback was registered.
sourcepub fn take_req_data(&mut self) -> Extensions
pub fn take_req_data(&mut self) -> Extensions
Returns the request data container, leaving an empty one in it’s place.
Trait Implementations
sourceimpl From<Message<RequestHead>> for Request<PayloadStream>
impl From<Message<RequestHead>> for Request<PayloadStream>
sourcefn from(head: Message<RequestHead>) -> Self
fn from(head: Message<RequestHead>) -> Self
Converts to this type from the input type.
sourceimpl<P> HttpMessage for Request<P>
impl<P> HttpMessage for Request<P>
sourcefn extensions(&self) -> Ref<'_, Extensions>
fn extensions(&self) -> Ref<'_, Extensions>
Request extensions
sourcefn extensions_mut(&self) -> RefMut<'_, Extensions>
fn extensions_mut(&self) -> RefMut<'_, Extensions>
Mutable reference to a the request’s extensions
type Stream = P
type Stream = P
Type of message payload stream
sourcefn take_payload(&mut self) -> Payload<P>
fn take_payload(&mut self) -> Payload<P>
Message payload stream
sourcefn content_type(&self) -> &str
fn content_type(&self) -> &str
Read the request content type. If request did not contain a Content-Type header, an empty string is returned. Read more
sourcefn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
fn encoding(&self) -> Result<&'static Encoding, ContentTypeError>
Get content type encoding Read more
sourcefn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
fn mime_type(&self) -> Result<Option<Mime>, ContentTypeError>
Convert the request content type to a known mime type.
sourcefn chunked(&self) -> Result<bool, ParseError>
fn chunked(&self) -> Result<bool, ParseError>
Check if request has chunked transfer encoding.
sourceimpl Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>> for ExpectHandler
impl Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>> for ExpectHandler
type Response = Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
type Response = Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
Responses given by the service.
type Future = Ready<Result<<ExpectHandler as Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::Response, <ExpectHandler as Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::Error>>
type Future = Ready<Result<<ExpectHandler as Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::Response, <ExpectHandler as Service<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::Error>>
The future response value.
sourceimpl ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>> for ExpectHandler
impl ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>> for ExpectHandler
type Response = Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
type Response = Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>
Responses given by the created services.
type Service = ExpectHandler
type Service = ExpectHandler
The kind of Service
created by this factory.
type Future = Ready<Result<<ExpectHandler as ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::Service, <ExpectHandler as ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::InitError>>
type Future = Ready<Result<<ExpectHandler as ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::Service, <ExpectHandler as ServiceFactory<Request<Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>>>>::InitError>>
The future of the Service
instance.g
sourcefn new_service(&self, _: Self::Config) -> Self::Future
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>> + 'static, Global>>> !RefUnwindSafe for Request<P>
impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>> !Send for Request<P>
impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>> !Sync for Request<P>
impl<P> Unpin for Request<P> where
P: Unpin,
impl<P = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>> + 'static, Global>>> !UnwindSafe for Request<P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more