pub struct RequestWriter<W> { /* private fields */ }Expand description
Sequential client output. Drive this lane concurrently with ResponseReader
so an upstream response can arrive before request production completes.
No dialing, pooling, detached task or Expect/Continue wait policy is hidden.
Implementations§
Source§impl<W: WritableStream> RequestWriter<W>
impl<W: WritableStream> RequestWriter<W>
pub fn new(writer: W) -> Self
Sourcepub fn is_reusable(&self) -> bool
pub fn is_reusable(&self) -> bool
Whether this output lane permits another request. This does not check completion of the independent response lane.
Sourcepub async fn write_request<B: ReadableBody>(
&mut self,
request: &mut Request<B>,
cancellation: &Cancellation,
) -> Result<bool, Error>
pub async fn write_request<B: ReadableBody>( &mut self, request: &mut Request<B>, cancellation: &Cancellation, ) -> Result<bool, Error>
Send one request. true permits another output message; the owner must
also finish the matching response before reusing the HTTP/1 connection.
The body is closed on return, including error and cancellation.
A body of known length is sent with Content-Length, and any trailers it produces are validated and dropped. On HTTP/1.1 a body of unknown length is chunked and keeps its trailers; HTTP/1.0 has no chunked framing, so it refuses such a body.
Sourcepub async fn begin_request(
&mut self,
metadata: &RequestMetadata,
cancellation: &Cancellation,
) -> Result<(), Error>
pub async fn begin_request( &mut self, metadata: &RequestMetadata, cancellation: &Cancellation, ) -> Result<(), Error>
Begin imperative output. A missing content length uses chunked HTTP/1.1 framing; declared fixed lengths are checked at every write and at EOF, and trailers written under them are validated and dropped. After failure or cancellation this lane must be retired.
Sourcepub async fn write_frame<D: AsRef<[u8]>>(
&mut self,
frame: BodyFrame<D>,
cancellation: &Cancellation,
) -> Result<(), Error>
pub async fn write_frame<D: AsRef<[u8]>>( &mut self, frame: BodyFrame<D>, cancellation: &Cancellation, ) -> Result<(), Error>
Directly encode and flush one frame. Taking the encoder before awaiting makes a dropped, partially completed write permanently non-resumable.
Sourcepub async fn flush(&mut self, cancellation: &Cancellation) -> Result<(), Error>
pub async fn flush(&mut self, cancellation: &Cancellation) -> Result<(), Error>
Flush pending transport output. A failure retires the lane; accepted bytes must not be replayed after an interrupted flush.