Struct async_web_server::HttpRequest
source · [−]pub struct HttpRequest<IO: AsyncRead + AsyncWrite + Unpin> { /* private fields */ }
Implementations
sourceimpl<IO: AsyncRead + AsyncWrite + Unpin> HttpRequest<IO>
impl<IO: AsyncRead + AsyncWrite + Unpin> HttpRequest<IO>
sourcepub fn into_inner(self) -> Request<BodyDecodeWithContinue<IO>>
pub fn into_inner(self) -> Request<BodyDecodeWithContinue<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 response100 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.
sourcepub fn from_inner(request: Request<BodyDecodeWithContinue<IO>>) -> Self
pub fn from_inner(request: Request<BodyDecodeWithContinue<IO>>) -> Self
The inverse of Self::into_inner().
sourcepub async fn response(self) -> Result<HttpResponse<IO>>
pub async fn response(self) -> Result<HttpResponse<IO>>
Move on to responding after consuming and discarding the remaining request body data.
sourcepub fn body(&mut self) -> &mut BodyDecodeWithContinue<IO>
pub fn body(&mut self) -> &mut BodyDecodeWithContinue<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.
sourcepub async fn body_string(&mut self) -> Result<String>
pub async fn body_string(&mut self) -> Result<String>
Read whole body as String. See Self::body for details.
sourcepub async fn body_vec(&mut self) -> Result<Vec<u8>>
pub async fn body_vec(&mut self) -> Result<Vec<u8>>
Read whole body as Vec. See Self::body for details.
sourcepub fn headers(&self) -> &HeaderMap
pub fn headers(&self) -> &HeaderMap
Access the headers as http::HeaderMap.
sourcepub fn method(&self) -> Method
pub fn method(&self) -> Method
Return the method as http::Method.
sourcepub fn version(&self) -> Version
pub fn version(&self) -> Version
Return the HTTP version as http::Version.
Auto Trait Implementations
impl<IO> !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> !UnwindSafe for HttpRequest<IO>
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