pub enum ResponsePipe {
Http1(Arc<Mutex<Encryption>>),
Http2(SendResponse<Bytes>),
Http3(RequestStream<SendStream<Bytes>, Bytes>),
}
Expand description
A pipe to send a Response
through.
You may also push requests if the pipe is ResponsePipe::Http2
by calling ResponseBodyPipe::push_request
. after you call ResponsePipe::send_response
.
Variants§
Http1(Arc<Mutex<Encryption>>)
An HTTP/1 stream to send a response.
Http2(SendResponse<Bytes>)
http2
only.An HTTP/2 response pipe.
Http3(RequestStream<SendStream<Bytes>, Bytes>)
http3
only.An HTTP/3 response pipe.
Implementations§
source§impl ResponsePipe
impl ResponsePipe
sourcepub async fn send_response(
self,
response: Response<()>,
end_of_stream: bool,
) -> Result<ResponseBodyPipe, Error>
pub async fn send_response( self, response: Response<()>, end_of_stream: bool, ) -> Result<ResponseBodyPipe, Error>
You must ensure the Response::version()
is correct before calling this function.
It can be guaranteed by first calling Self::ensure_version()
. Also call
Self::ensure_length()
.
It is critical to ResponseBodyPipe::close()
, else the message won’t be seen as fully transmitted.
§Errors
Passes any errors from writing to the stream. see AsyncWriteExt::write()
and
[h2::server::SendResponse::send_response()
] for more info.
sourcepub fn ensure_length<T>(&self, response: &mut Response<T>, len: u64)
pub fn ensure_length<T>(&self, response: &mut Response<T>, len: u64)
Ensures the length of the response
using the variant of ResponsePipe
.
sourcepub fn ensure_version<T>(&self, response: &mut Response<T>)
pub fn ensure_version<T>(&self, response: &mut Response<T>)
Ensures the version of the response
using the variant of ResponsePipe
.