Skip to content

Commit 619ecf0

Browse files
committed
docs(ext): improve extensions module overview
1 parent b8affd8 commit 619ecf0

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

src/ext/mod.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1-
//! HTTP extensions.
1+
//! Extensions for HTTP messages in Hyper.
2+
//!
3+
//! This module provides types and utilities that extend the capabilities of HTTP requests and responses
4+
//! in Hyper. Extensions are additional pieces of information or features that can be attached to HTTP
5+
//! messages via the [`http::Extensions`] map, which is
6+
//! accessible through methods like [`http::Request::extensions`] and [`http::Response::extensions`].
7+
//!
8+
//! # What are extensions?
9+
//!
10+
//! Extensions allow Hyper to associate extra metadata or behaviors with HTTP messages, beyond the standard
11+
//! headers and body. These can be used by advanced users and library authors to access protocol-specific
12+
//! features, track original header casing, handle informational responses, and more.
13+
//!
14+
//! # How to access extensions
15+
//!
16+
//! Extensions are stored in the `Extensions` map of a request or response. You can access them using:
17+
//!
18+
//! ```rust
19+
//! if let Some(ext) = response.extensions().get::<hyper::ext::ReasonPhrase>() {
20+
//! // use the extension
21+
//! }
22+
//! ```
23+
//!
24+
//! # Extension Groups
25+
//!
26+
//! The extensions in this module can be grouped as follows:
27+
//!
28+
//! - **HTTP/1 Reason Phrase**: [`ReasonPhrase`] — Access non-canonical reason phrases in HTTP/1 responses.
29+
//! - **Informational Responses**: [`on_informational`] — Register callbacks for 1xx HTTP/1 responses on the client.
30+
//! - **Header Case Tracking**: Internal types for tracking the original casing and order of headers as received.
31+
//! - **HTTP/2 Protocol Extensions**: [`Protocol`] — Access the `:protocol` pseudo-header for Extended CONNECT in HTTP/2.
32+
//!
33+
//! Some extensions are only available for specific protocols (HTTP/1 or HTTP/2) or use cases (client, server, FFI).
34+
//!
35+
//! See the documentation on each item for details about its usage and requirements.
236
337
#[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))]
438
use bytes::Bytes;

0 commit comments

Comments
 (0)