pub enum Body<'b, R> {
Raw(PartiallyRead<'b, R>),
ContentLen(ContentLenRead<PartiallyRead<'b, R>>),
Chunked(ChunkedRead<'b, PartiallyRead<'b, R>>),
}Expand description
Represents an incoming HTTP request stream body
Implements the Read trait to read the body from the stream
Variants§
Raw(PartiallyRead<'b, R>)
The body is raw and should be read as is (only possible for HTTP responses with connection = Close)
ContentLen(ContentLenRead<PartiallyRead<'b, R>>)
The body is of a known length (Content-Length)
Chunked(ChunkedRead<'b, PartiallyRead<'b, R>>)
The body is chunked (Transfer-Encoding: chunked)
Implementations§
Source§impl<'b, R> Body<'b, R>where
R: Read,
impl<'b, R> Body<'b, R>where
R: Read,
Sourcepub fn new(
body_type: BodyType,
buf: &'b mut [u8],
read_len: usize,
input: R,
) -> Self
pub fn new( body_type: BodyType, buf: &'b mut [u8], read_len: usize, input: R, ) -> Self
Create a new body
Parameters:
body_type: The type of the body, as resolved usingBodyType::resolvebuf: The buffer to use for reading the bodyread_len: The length of the buffer that has already been read when processing the icoming headersinput: The raw input stream
Sourcepub fn needs_close(&self) -> bool
pub fn needs_close(&self) -> bool
Check if the body needs to be closed (i.e. the underlying input stream cannot be re-used for Keep-Alive connections)
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the body has been completely read
Sourcepub fn as_raw_reader(&mut self) -> &mut R
pub fn as_raw_reader(&mut self) -> &mut R
Return a mutable reference to the underlying raw reader
Trait Implementations§
Source§impl<R> Read for Body<'_, R>where
R: Read,
impl<R> Read for Body<'_, R>where
R: Read,
Source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreAuto Trait Implementations§
impl<'b, R> Freeze for Body<'b, R>where
R: Freeze,
impl<'b, R> RefUnwindSafe for Body<'b, R>where
R: RefUnwindSafe,
impl<'b, R> Send for Body<'b, R>where
R: Send,
impl<'b, R> Sync for Body<'b, R>where
R: Sync,
impl<'b, R> Unpin for Body<'b, R>where
R: Unpin,
impl<'b, R> !UnwindSafe for Body<'b, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more