@@ -62,11 +62,26 @@ pub(crate) use informational::OnInformational;
62
62
#[ cfg( all( feature = "http1" , feature = "client" , feature = "ffi" ) ) ]
63
63
pub ( crate ) use informational:: { on_informational_raw, OnInformationalCallback } ;
64
64
65
+
65
66
#[ cfg( feature = "http2" ) ]
66
- /// Represents the `:protocol` pseudo-header used by
67
- /// the [Extended CONNECT Protocol].
67
+ /// Extension type representing the `:protocol` pseudo-header in HTTP/2.
68
+ ///
69
+ /// The `Protocol` extension allows access to the value of the `:protocol` pseudo-header
70
+ /// used by the [Extended CONNECT Protocol](https://datatracker.ietf.org/doc/html/rfc8441#section-4).
71
+ /// This extension is only sent on HTTP/2 CONNECT requests, most commonly with the value `websocket`.
72
+ ///
73
+ /// # Example
68
74
///
69
- /// [Extended CONNECT Protocol]: https://datatracker.ietf.org/doc/html/rfc8441#section-4
75
+ /// ```rust
76
+ /// use hyper::ext::Protocol;
77
+ /// use http::{Request, Method, Version};
78
+ ///
79
+ /// let mut req = Request::new(());
80
+ /// *req.method_mut() = Method::CONNECT;
81
+ /// *req.version_mut() = Version::HTTP_2;
82
+ /// req.extensions_mut().insert(Protocol::from_static("websocket"));
83
+ /// // Now the request will include the `:protocol` pseudo-header with value "websocket"
84
+ /// ```
70
85
#[ derive( Clone , Eq , PartialEq ) ]
71
86
pub struct Protocol {
72
87
inner : h2:: ext:: Protocol ,
0 commit comments