From 039ba390d3f25dff18d58af6d4ce0ccc516fc464 Mon Sep 17 00:00:00 2001 From: Samuel Cobb Date: Fri, 30 Jan 2026 18:04:43 +0000 Subject: [PATCH] docs: update client-http1-middleware docs --- src/client/mod.rs | 4 +++- src/client/service.rs | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 68dcc338..c53c8c26 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -3,10 +3,12 @@ /// Legacy implementations of `connect` module and `Client` #[cfg(feature = "client-legacy")] pub mod legacy; -pub mod service; #[cfg(feature = "client-pool")] pub mod pool; +#[cfg(feature = "client-pool")] +pub mod service; + #[cfg(feature = "client-proxy")] pub mod proxy; diff --git a/src/client/service.rs b/src/client/service.rs index 50c8f0fb..307c7f64 100644 --- a/src/client/service.rs +++ b/src/client/service.rs @@ -1,4 +1,4 @@ -//! todo +//! Middleware services for normalizing request URIs and Host headers. use std::task::{Context, Poll}; @@ -6,13 +6,18 @@ use http::header::{HeaderValue, HOST}; use http::{Method, Request, Uri}; use tower_service::Service; -/// todo +/// A middleware that ensures the Host header matches the URI's authority. +/// +/// Particularly useful for HTTP/1 clients and proxies, where the Host +/// header is mandatory and should be derived from the request URI. #[derive(Clone, Debug)] pub struct SetHost { inner: S, } -/// todo +/// A middleware that modifies the request target for HTTP/1 semantics. +/// +/// Ensures CONNECT uses authority-form, and all other methods use origin-form. #[derive(Clone, Debug)] pub struct Http1RequestTarget { inner: S, @@ -21,7 +26,7 @@ pub struct Http1RequestTarget { // ===== impl SetHost ===== impl SetHost { - /// todo + /// Create a new `SetHost` middleware wrapping the given service. pub fn new(inner: S) -> Self { SetHost { inner } } @@ -79,7 +84,7 @@ fn is_schema_secure(uri: &Uri) -> bool { // ===== impl Http1RequestTarget ===== impl Http1RequestTarget { - /// todo + /// Create a new `Http1RequestTarget` middleware wrapping the given service. pub fn new(inner: S) -> Self { Http1RequestTarget { inner } }