pub struct HttpRequest<IO: AsyncRead + AsyncWrite + Unpin = TcpOrTlsStream> { /* private fields */ }
Implementations§
Source§impl<IO: AsyncRead + AsyncWrite + Unpin> HttpRequest<IO>
impl<IO: AsyncRead + AsyncWrite + Unpin> HttpRequest<IO>
Sourcepub fn into_inner(
self,
) -> Request<BodyDecodeWithContinue<BodyDecodeWithContinueState, IO>>
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 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<BodyDecodeWithContinueState, IO>>,
) -> Self
pub fn from_inner( request: Request<BodyDecodeWithContinue<BodyDecodeWithContinueState, 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,
) -> BodyDecodeWithContinue<&mut BodyDecodeWithContinueState, &mut IO>
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.
Sourcepub async fn body_string(&mut self, limit: usize) -> Result<String>
pub async fn body_string(&mut self, limit: usize) -> Result<String>
Read whole body as String. See Self::body for details.
Sourcepub async fn body_vec(&mut self, limit: usize) -> Result<Vec<u8>>
pub async fn body_vec(&mut self, limit: usize) -> 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.