Enum kvarn::application::Body
source · pub enum Body {
Bytes(ByteBody),
Http1(Http1Body<Encryption>),
Http2(RecvStream),
Http3(RequestStream<RecvStream, Bytes>),
}
Expand description
A body of a Request
.
The inner variables are streams. To get the bytes, use Body::read_to_bytes()
when needed.
Also see FatRequest
.
Variants§
Bytes(ByteBody)
A body of Bytes
.
Can be used by HTTP/2 push to simulate a GET request, or any other extensions which wants a Kvarn response.
Http1(Http1Body<Encryption>)
A buffered HTTP/1 body.
While the HTTP/1 headers were read, it reads too much
and some of the body will be read.
Therefore, the already read bytes are stored.
Body::read_to_bytes
leverages this and just
continues writing to the buffer.
Http2(RecvStream)
Available on crate feature
http2
only.An HTTP/2 body provided by h2
.
Http3(RequestStream<RecvStream, Bytes>)
Available on crate feature
http3
only.An HTTP/3 body provided by [h3
].
Implementations§
source§impl Body
impl Body
sourcepub async fn read_to_bytes(&mut self, max_len: usize) -> Result<Bytes>
pub async fn read_to_bytes(&mut self, max_len: usize) -> Result<Bytes>
Reads all bytes from Body
to a Bytes
.
Errors
Passes any errors returned from the inner reader.
See super::Http1Body::read_to_bytes()
and h2::RecvStream::poll_data()
for more info.