From 58a25eb7dcf749cdfff1e40d21a72324085f8784 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Thu, 17 Sep 2020 20:16:20 +0200 Subject: [PATCH] docs(body): Sender: Add a note about abnormal body closing (#2283) --- src/body/body.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/body/body.rs b/src/body/body.rs index 355f0d87..a83bad0d 100644 --- a/src/body/body.rs +++ b/src/body/body.rs @@ -75,10 +75,19 @@ enum DelayEof { Eof(DelayEofUntil), } -/// A sender half used with `Body::channel()`. +/// A sender half created through [`Body::channel()`]. /// -/// Useful when wanting to stream chunks from another thread. See -/// [`Body::channel`](Body::channel) for more. +/// Useful when wanting to stream chunks from another thread. +/// +/// ## Body Closing +/// +/// Note that the request body will always be closed normally when the sender is dropped (meaning +/// that the empty terminating chunk will be sent to the remote). If you desire to close the +/// connection with an incomplete response (e.g. in the case of an error during asynchronous +/// processing), call the [`Sender::abort()`] method to abort the body in an abnormal fashion. +/// +/// [`Body::channel()`]: struct.Body.html#method.channel +/// [`Sender::abort()`]: struct.Sender.html#method.abort #[must_use = "Sender does nothing unless sent on"] pub struct Sender { want_rx: watch::Receiver,