diff --git a/linkerd/app/outbound/src/http/server.rs b/linkerd/app/outbound/src/http/server.rs index 2ba08695ab..32221e0d92 100644 --- a/linkerd/app/outbound/src/http/server.rs +++ b/linkerd/app/outbound/src/http/server.rs @@ -1,10 +1,9 @@ -use super::{IdentityRequired, Logical, ProxyConnectionClose}; +use super::{IdentityRequired, ProxyConnectionClose}; use crate::{http, trace_labels, Outbound}; use linkerd_app_core::{ errors, http_tracing, io, svc::{self, ExtractParam}, - transport::addrs::*, - Addr, Error, Result, + Error, Result, }; #[derive(Copy, Clone, Debug)] @@ -12,9 +11,6 @@ pub(crate) struct ServerRescue { emit_headers: bool, } -#[derive(Copy, Clone, Debug)] -struct Target(T); - impl Outbound { /// Builds a [`svc::NewService`] stack that prepares HTTP requests to be /// proxied. @@ -37,7 +33,8 @@ impl Outbound { >, > where - T: svc::Param + 'static, + // Target + T: svc::Param, // HTTP outbound stack N: svc::NewService + Clone + Send + Sync + 'static, NSvc: svc::Service, Response = http::Response>, @@ -80,14 +77,7 @@ impl Outbound { ) // Convert origin form HTTP/1 URIs to absolute form for Hyper's // `Client`. - .push(http::NewNormalizeUri::layer_via(|target: &T| { - let addr = match target.param() { - Logical::Route(addr, _) => Addr::from(addr), - Logical::Forward(Remote(ServerAddr(addr)), _) => Addr::from(addr), - }; - - http::normalize_uri::DefaultAuthority(Some(addr.to_http_authority())) - })) + .push(http::NewNormalizeUri::layer()) // Record when a HTTP/1 URI originated in absolute form .push_on_service(http::normalize_uri::MarkAbsoluteForm::layer()) .push(svc::ArcNewService::layer()) diff --git a/linkerd/app/outbound/src/ingress.rs b/linkerd/app/outbound/src/ingress.rs index c24679fc5c..b66f7ae806 100644 --- a/linkerd/app/outbound/src/ingress.rs +++ b/linkerd/app/outbound/src/ingress.rs @@ -258,6 +258,15 @@ impl svc::Param for Http { } } +impl svc::Param for Http { + fn param(&self) -> http::normalize_uri::DefaultAuthority { + http::normalize_uri::DefaultAuthority(match &self.parent { + http::Logical::Route(addr, _) => Some(addr.as_http_authority()), + http::Logical::Forward(..) => None, + }) + } +} + impl TryFrom>> for Http { type Error = ProfileRequired; diff --git a/linkerd/app/outbound/src/protocol.rs b/linkerd/app/outbound/src/protocol.rs index 2915a0b0d7..79146776a0 100644 --- a/linkerd/app/outbound/src/protocol.rs +++ b/linkerd/app/outbound/src/protocol.rs @@ -132,3 +132,12 @@ where self.parent.param() } } + +impl svc::Param for Http +where + T: svc::Param, +{ + fn param(&self) -> http::normalize_uri::DefaultAuthority { + self.parent.param() + } +} diff --git a/linkerd/app/outbound/src/sidecar.rs b/linkerd/app/outbound/src/sidecar.rs index 3cbdb6ceec..72a6d72b95 100644 --- a/linkerd/app/outbound/src/sidecar.rs +++ b/linkerd/app/outbound/src/sidecar.rs @@ -105,6 +105,15 @@ impl svc::Param for Sidecar { } } +impl svc::Param for Sidecar { + fn param(&self) -> http::normalize_uri::DefaultAuthority { + http::normalize_uri::DefaultAuthority(self.profile.as_ref().and_then(|p| { + p.logical_addr() + .map(|profiles::LogicalAddr(a)| a.as_http_authority()) + })) + } +} + impl svc::Param for Sidecar { fn param(&self) -> http::Logical { if let Some(profile) = self.profile.clone() {