Struct HttpRequest

Source
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, limit: usize) -> Result<String>

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

Source

pub async fn body_vec(&mut self, limit: usize) -> 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 Debug for HttpRequest

Source§

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

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

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

Source§

fn is_tls(&self) -> bool

Auto Trait Implementations§

§

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

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

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

Source§

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

Source§

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

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

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

Source§

fn vzip(self) -> V