pub struct HttpRequest<IO: AsyncRead + AsyncWrite + Unpin = TcpOrTlsStream> { /* private fields */ }

Implementations§

source§

impl<IO: AsyncRead + AsyncWrite + Unpin> HttpRequest<IO>

source

pub fn into_inner( self ) -> Request<BodyDecodeWithContinue<BodyDecodeWithContinueState, IO>>

Direct access to the request as http::Request with body decoder and underlying transport. The transport may be extracted using

let transport = request.into_inner();

Doing this after starting to read the body may lead to one of these situations:

  • The meaning of remaining data read from the transport is ambiguous, if the body has been partially consumed and is encoded using chunked transfer encoding.
  • If the request includes the Expect: 100-continue header and if the body reader has been polled, but did not yield any data yet, the informational response 100 Continue may have been fully, partially or not sent on the transport.

Reasoning about the protocol state is only trivial before calling Self::body() and after consuming the whole body.

source

pub fn from_inner( request: Request<BodyDecodeWithContinue<BodyDecodeWithContinueState, IO>> ) -> Self

The inverse of Self::into_inner().

source

pub async fn response(self) -> Result<HttpResponse<IO>>

Move on to responding after consuming and discarding the remaining request body data.

source

pub fn body( &mut self ) -> BodyDecodeWithContinue<&mut BodyDecodeWithContinueState, &mut IO>

Access the request body data stream as [futures::io::AsyncRead]. If the request includes the Expect: 100-continue the informational response 100 Continue will be sent to the client before the reader emits any body data.

source

pub async fn body_string(&mut self) -> Result<String>

Read whole body as String. See Self::body for details.

source

pub async fn body_vec(&mut self) -> Result<Vec<u8>>

Read whole body as Vec. See Self::body for details.

source

pub fn headers(&self) -> &HeaderMap

Access the headers as http::HeaderMap.

source

pub fn uri(&self) -> &Uri

Access the URI as http::Uri.

source

pub fn method(&self) -> Method

Return the method as http::Method.

source

pub fn version(&self) -> Version

Return the HTTP version as http::Version.

Trait Implementations§

source§

impl<IO: AsyncRead + AsyncWrite + Unpin + IsTls> IsTls for HttpRequest<IO>

source§

fn is_tls(&self) -> bool

Auto Trait Implementations§

§

impl<IO = TcpOrTlsStream> !RefUnwindSafe for HttpRequest<IO>

§

impl<IO> Send for HttpRequest<IO>where IO: Send,

§

impl<IO> Sync for HttpRequest<IO>where IO: Sync,

§

impl<IO> Unpin for HttpRequest<IO>

§

impl<IO = TcpOrTlsStream> !UnwindSafe for HttpRequest<IO>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T> AsTaggedExplicit<'a> for Twhere T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self>

§

impl<'a, T> AsTaggedImplicit<'a> for Twhere T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self>

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V