pub enum ResponseBodyPipe {
Http1(Arc<Mutex<Encryption>>),
Http2(SendStream<Bytes>, H2SendResponse),
Http3(Box<RequestStream<SendStream<Bytes>, Bytes>>),
}Expand description
A pipe to send a body after the Response is sent by
ResponsePipe::send_response.
The AsyncWriteExt::shutdown does nothing, and will immediately return with Ok(())
Variants§
Http1(Arc<Mutex<Encryption>>)
HTTP/1 pipe
Http2(SendStream<Bytes>, H2SendResponse)
http2 only.HTTP/2 pipe
Http3(Box<RequestStream<SendStream<Bytes>, Bytes>>)
http3 only.HTTP/3 pipe
Implementations§
source§impl ResponseBodyPipe
impl ResponseBodyPipe
sourcepub async fn send(&mut self, data: Bytes) -> Result<(), Error>
pub async fn send(&mut self, data: Bytes) -> Result<(), Error>
Sends data as the body.
§Errors
Passes any errors from writing to the stream.
See AsyncWriteExt::write_all() and [h2::SendStream::send_data()].
sourcepub async fn flush(&mut self) -> Result<(), Error>
pub async fn flush(&mut self) -> Result<(), Error>
Only does something for HTTP/1, since the other protocols are not implemented as streams.
To shut down the stream, it is necessary to call ResponseBodyPipe::close.
§Errors
Passes any errors from flushing the stream.
sourcepub async fn send_with_wait(
&mut self,
data: Bytes,
_chunk_size: usize,
) -> Result<(), Error>
pub async fn send_with_wait( &mut self, data: Bytes, _chunk_size: usize, ) -> Result<(), Error>
Same as ResponseBodyPipe::send but tries its best to wait for the data to actually
be sent, freeing up previous Bytes being sent before.
chunk_size is the expected size of data used to negotiate and wait for capacity
changes. A value of ~10MB is often good (chunk_size is measured in bytes).
§Errors
Same as ResponseBodyPipe::send.
sourcepub fn push_request(
&mut self,
request: Request<()>,
) -> Result<PushedResponsePipe, Error>
pub fn push_request( &mut self, request: Request<()>, ) -> Result<PushedResponsePipe, Error>
Pushes request to client.
§Errors
If you try to push if self is ResponsePipe::Http1, an Error::UnsupportedPush is returned.
Returns errors from [h2::server::SendResponse::push_request()].