Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
15 changes: 10 additions & 5 deletions src/client/service.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
//! todo
//! Middleware services for normalizing request URIs and Host headers.

use std::task::{Context, Poll};

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<S> {
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<S> {
inner: S,
Expand All @@ -21,7 +26,7 @@ pub struct Http1RequestTarget<S> {
// ===== impl SetHost =====

impl<S> SetHost<S> {
/// todo
/// Create a new `SetHost` middleware wrapping the given service.
pub fn new(inner: S) -> Self {
SetHost { inner }
}
Expand Down Expand Up @@ -79,7 +84,7 @@ fn is_schema_secure(uri: &Uri) -> bool {
// ===== impl Http1RequestTarget =====

impl<S> Http1RequestTarget<S> {
/// todo
/// Create a new `Http1RequestTarget` middleware wrapping the given service.
pub fn new(inner: S) -> Self {
Http1RequestTarget { inner }
}
Expand Down