Skip to content

Commit 07a448e

Browse files
authored
http: Put normalize_uri back on the stack (#659)
In b59172a, we moved the NormalizeUri logic into the HTTP server, but this misses downgraded requests. This change extracts NormalizeUri from the server, putting it back on the HTTP stack so that it can be applied after `orig_proto::Downgrade` is applied on the inbound proxy.
1 parent 445e7dc commit 07a448e

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

linkerd/app/inbound/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ impl Config {
346346
// Used by tap.
347347
.push_http_insert_target()
348348
.check_new_service::<tls::accept::Meta, http::Request<_>>()
349+
.push(svc::layer::mk(http::normalize_uri::MakeNormalizeUri::new))
349350
.push_on_response(
350351
svc::layers()
351352
.push(http_admit_request)

linkerd/app/outbound/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ impl Config {
523523
.box_http_request()
524524
.box_http_response(),
525525
)
526+
.push(svc::layer::mk(http::normalize_uri::MakeNormalizeUri::new))
526527
.instrument(
527528
|addrs: &listen::Addrs| info_span!("source", target.addr = %addrs.target_addr()),
528529
)

linkerd/proxy/http/src/detect.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::{
22
self as http,
33
glue::{Body, HyperServerSvc},
44
h2::Settings as H2Settings,
5-
normalize_uri::{MakeNormalizeUri, NormalizeUri},
65
trace, upgrade, Version as HttpVersion,
76
};
87
use futures::prelude::*;
@@ -11,7 +10,6 @@ use linkerd2_error::Error;
1110
use linkerd2_io::{self as io, PrefixedIo};
1211
use std::{
1312
future::Future,
14-
net::SocketAddr,
1513
pin::Pin,
1614
task::{Context, Poll},
1715
time::Duration,
@@ -74,7 +72,6 @@ impl<F, H> DetectHttp<F, H> {
7472
impl<T, F, S> Service<T> for DetectHttp<F, S>
7573
where
7674
T: Clone + Send + 'static,
77-
for<'t> &'t T: Into<SocketAddr>,
7875
F: tower::Service<T> + Clone + Send + 'static,
7976
F::Error: Into<Error>,
8077
F::Response: Send + 'static,
@@ -84,7 +81,7 @@ where
8481
S::Response: Send + 'static,
8582
S::Future: Send + 'static,
8683
{
87-
type Response = AcceptHttp<F::Response, NormalizeUri<S::Response>>;
84+
type Response = AcceptHttp<F::Response, S::Response>;
8885
type Error = Error;
8986
type Future =
9087
Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;
@@ -96,7 +93,7 @@ where
9693
fn call(&mut self, target: T) -> Self::Future {
9794
let drain = self.drain.clone();
9895
let tcp = self.tcp.clone();
99-
let http = MakeNormalizeUri::new(self.http.clone());
96+
let http = self.http.clone();
10097
let server = self.server.clone();
10198
let timeout = self.timeout;
10299

linkerd/proxy/http/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod h1;
1414
pub mod h2;
1515
pub mod header_from_target;
1616
pub mod insert;
17-
mod normalize_uri;
17+
pub mod normalize_uri;
1818
pub mod orig_proto;
1919
pub mod override_authority;
2020
pub mod strip_header;

linkerd/proxy/http/src/normalize_uri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub struct NormalizeUri<S> {
3939
// === impl MakeNormalizeUri ===
4040

4141
impl<N> MakeNormalizeUri<N> {
42-
pub(crate) fn new(inner: N) -> Self {
42+
pub fn new(inner: N) -> Self {
4343
Self { inner }
4444
}
4545
}

0 commit comments

Comments
 (0)