1- //! todo
1+ //! Middleware services for normalizing request URIs and Host headers.
22
33use std:: task:: { Context , Poll } ;
44
55use http:: header:: { HeaderValue , HOST } ;
66use http:: { Method , Request , Uri } ;
77use tower_service:: Service ;
88
9- /// todo
9+ /// A middleware that ensures the Host header matches the URI's authority.
10+ ///
11+ /// Particularly useful for HTTP/1 clients and proxies, where the Host
12+ /// header is mandatory and should be derived from the request URI.
1013#[ derive( Clone , Debug ) ]
1114pub struct SetHost < S > {
1215 inner : S ,
1316}
1417
15- /// todo
18+ /// A middleware that modifies the request target for HTTP/1 semantics.
19+ ///
20+ /// Ensures CONNECT uses authority-form, and all other methods use origin-form.
1621#[ derive( Clone , Debug ) ]
1722pub struct Http1RequestTarget < S > {
1823 inner : S ,
@@ -21,7 +26,7 @@ pub struct Http1RequestTarget<S> {
2126// ===== impl SetHost =====
2227
2328impl < S > SetHost < S > {
24- /// todo
29+ /// Create a new `SetHost` middleware wrapping the given service.
2530 pub fn new ( inner : S ) -> Self {
2631 SetHost { inner }
2732 }
@@ -79,7 +84,7 @@ fn is_schema_secure(uri: &Uri) -> bool {
7984// ===== impl Http1RequestTarget =====
8085
8186impl < S > Http1RequestTarget < S > {
82- /// todo
87+ /// Create a new `Http1RequestTarget` middleware wrapping the given service.
8388 pub fn new ( inner : S ) -> Self {
8489 Http1RequestTarget { inner }
8590 }
0 commit comments