From a1d4eb7f8d78438e4494567386e0d7cd2a571ffc Mon Sep 17 00:00:00 2001 From: glendc Date: Mon, 16 Sep 2024 11:35:04 +0200 Subject: [PATCH] add more trace calls to request ctx authority decider --- rama-net/src/http/request_context.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/rama-net/src/http/request_context.rs b/rama-net/src/http/request_context.rs index a375bd90..f8f1c800 100644 --- a/rama-net/src/http/request_context.rs +++ b/rama-net/src/http/request_context.rs @@ -46,12 +46,16 @@ impl TryFrom<(&Context, &Request)> for RequestContext let authority = uri .host() - .and_then(|h| Host::try_from(h).ok().map(|h| (h, default_port).into())) + .and_then(|h| Host::try_from(h).ok().map(|h| { + tracing::trace!(uri = %uri, host = %h, "request context: detected host from (abs) uri"); + (h, default_port).into() + })) .or_else(|| { ctx.get::().and_then(|f| { f.client_host().map(|fauth| { let (host, port) = fauth.clone().into_parts(); let port = port.unwrap_or(default_port); + tracing::trace!(uri = %uri, host = %host, "request context: detected host from forwarded info"); (host, port).into() }) }) @@ -61,7 +65,10 @@ impl TryFrom<(&Context, &Request)> for RequestContext .get(rama_http_types::header::HOST) .and_then(|host| { host.try_into() // try to consume as Authority, otherwise as Host - .or_else(|_| Host::try_from(host).map(|h| (h, default_port).into())) + .or_else(|_| Host::try_from(host).map(|h| { + tracing::trace!(uri = %uri, host = %h, "request context: detected host from host header"); + (h, default_port).into() + })) .ok() }) }) @@ -110,12 +117,16 @@ impl TryFrom<(&Context, &Parts)> for RequestContext { let authority = uri .host() - .and_then(|h| Host::try_from(h).ok().map(|h| (h, default_port).into())) + .and_then(|h| Host::try_from(h).ok().map(|h| { + tracing::trace!(uri = %uri, host = %h, "request context: detected host from (abs) uri"); + (h, default_port).into() + })) .or_else(|| { ctx.get::().and_then(|f| { f.client_host().map(|fauth| { let (host, port) = fauth.clone().into_parts(); let port = port.unwrap_or(default_port); + tracing::trace!(uri = %uri, host = %host, "request context: detected host from forwarded info"); (host, port).into() }) }) @@ -126,7 +137,10 @@ impl TryFrom<(&Context, &Parts)> for RequestContext { .get(rama_http_types::header::HOST) .and_then(|host| { host.try_into() // try to consume as Authority, otherwise as Host - .or_else(|_| Host::try_from(host).map(|h| (h, default_port).into())) + .or_else(|_| Host::try_from(host).map(|h| { + tracing::trace!(uri = %uri, host = %h, "request context: detected host from host header"); + (h, default_port).into() + })) .ok() }) })