From a34c8a3231a9c00e5d00ada81cd8676d45f6691c Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Thu, 12 Sep 2024 14:05:56 +0200 Subject: [PATCH] Don't require a SocketAddr to make a SelfRequestOrigin This was forcing consumers who only had a DNS authority to resolve to an IP address ahead of time instead of just passing the authority along. Signed-off-by: Ryan Levick --- crates/factor-outbound-http/src/lib.rs | 9 ++++----- crates/trigger-http/src/server.rs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/factor-outbound-http/src/lib.rs b/crates/factor-outbound-http/src/lib.rs index 3feb70508..8c4c28c26 100644 --- a/crates/factor-outbound-http/src/lib.rs +++ b/crates/factor-outbound-http/src/lib.rs @@ -4,7 +4,7 @@ mod wasi; pub mod wasi_2023_10_18; pub mod wasi_2023_11_10; -use std::{net::SocketAddr, sync::Arc}; +use std::sync::Arc; use anyhow::Context; use http::{ @@ -138,13 +138,12 @@ pub struct SelfRequestOrigin { } impl SelfRequestOrigin { - pub fn create(scheme: Scheme, addr: &SocketAddr) -> anyhow::Result { + pub fn create(scheme: Scheme, auth: &str) -> anyhow::Result { Ok(SelfRequestOrigin { scheme, - authority: addr - .to_string() + authority: auth .parse() - .with_context(|| format!("address '{addr}' is not a valid authority"))?, + .with_context(|| format!("address '{auth}' is not a valid authority"))?, }) } diff --git a/crates/trigger-http/src/server.rs b/crates/trigger-http/src/server.rs index 1025ab884..6ce336f0c 100644 --- a/crates/trigger-http/src/server.rs +++ b/crates/trigger-http/src/server.rs @@ -244,7 +244,7 @@ impl HttpServer { .context( "The wasi HTTP trigger was configured without the required wasi outbound http support", )?; - let origin = SelfRequestOrigin::create(server_scheme, &self.listen_addr)?; + let origin = SelfRequestOrigin::create(server_scheme, &self.listen_addr.to_string())?; outbound_http.set_self_request_origin(origin); outbound_http.set_request_interceptor(OutboundHttpInterceptor::new(self.clone()))?;