Skip to content

Commit 1a0b3d5

Browse files
author
MsfPablo
committed
docs: expand crate-level cancel safety section with HTTP/1 vs HTTP/2
1 parent fca07bd commit 1a0b3d5

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,23 @@
3333
//! # Cancel safety
3434
//!
3535
//! Futures returned by hyper are cancel safe: dropping a future before it
36-
//! completes is the supported way to cancel the operation. See the
37-
//! documentation on individual futures — for example `SendRequest::send_request`
38-
//! in `client::conn::http1` and `client::conn::http2` — for the protocol-
39-
//! specific behavior on cancellation.
36+
//! completes is the supported way to cancel the operation. The protocol in
37+
//! use changes what that cancellation actually does on the wire:
38+
//!
39+
//! - **HTTP/1** has no in-protocol way to abort a single request without
40+
//! affecting the shared connection, so dropping an in-flight request future
41+
//! closes the underlying TCP connection. Any subsequent call on the same
42+
//! `SendRequest` returns a `canceled` error; the connection cannot be
43+
//! reused.
44+
//! - **HTTP/2** resets the single stream with `RST_STREAM` (`CANCEL` error
45+
//! code) and notifies the peer immediately rather than continuing to
46+
//! deliver a response body that would be discarded. The shared connection
47+
//! stays usable for other in-flight and future requests.
48+
//!
49+
//! See the documentation on individual futures — for example
50+
//! `SendRequest::send_request` in `client::conn::http1` and the equivalent
51+
//! in `client::conn::http2` — for the protocol-specific behavior on
52+
//! cancellation.
4053
//!
4154
//! # Optional Features
4255
//!

0 commit comments

Comments
 (0)