diff --git a/ipa-core/src/helpers/transport/query/mod.rs b/ipa-core/src/helpers/transport/query/mod.rs index 67553941e..cd3e389d1 100644 --- a/ipa-core/src/helpers/transport/query/mod.rs +++ b/ipa-core/src/helpers/transport/query/mod.rs @@ -6,7 +6,6 @@ use std::{ }; pub use hybrid::HybridQueryParams; -use hyper::Uri; use serde::{Deserialize, Deserializer, Serialize}; use crate::{ @@ -188,7 +187,7 @@ impl RouteParams for &PrepareQuery { pub enum QueryInput { FromUrl { query_id: QueryId, - url: Uri, + url: String, }, Inline { query_id: QueryId, @@ -197,12 +196,14 @@ pub enum QueryInput { } impl QueryInput { + #[must_use] pub fn query_id(&self) -> QueryId { match self { Self::FromUrl { query_id, .. } | Self::Inline { query_id, .. } => *query_id, } } + #[must_use] pub fn input_stream(self) -> Option { match self { Self::Inline { input_stream, .. } => Some(input_stream), @@ -210,7 +211,8 @@ impl QueryInput { } } - pub fn url(&self) -> Option<&Uri> { + #[must_use] + pub fn url(&self) -> Option<&str> { match self { Self::FromUrl { url, .. } => Some(url), Self::Inline { .. } => None, diff --git a/ipa-core/src/net/http_serde.rs b/ipa-core/src/net/http_serde.rs index 47ed0708e..8cc2be8ed 100644 --- a/ipa-core/src/net/http_serde.rs +++ b/ipa-core/src/net/http_serde.rs @@ -355,7 +355,7 @@ pub mod query { self.query_input.query_id().as_ref(), )) .build()?; - let query_input_url = self.query_input.url().cloned(); + let query_input_url = self.query_input.url().map(ToOwned::to_owned); let body = self .query_input .input_stream() @@ -365,7 +365,7 @@ pub mod query { if let Some(url) = query_input_url { request.headers_mut().unwrap().insert( &HTTP_QUERY_INPUT_URL_HEADER, - HeaderValue::try_from(url.to_string()).unwrap(), + HeaderValue::try_from(url).unwrap(), ); } Ok(request.body(body)?) diff --git a/ipa-core/src/net/server/handlers/query/input.rs b/ipa-core/src/net/server/handlers/query/input.rs index 7c881049f..1de6ea570 100644 --- a/ipa-core/src/net/server/handlers/query/input.rs +++ b/ipa-core/src/net/server/handlers/query/input.rs @@ -127,9 +127,7 @@ mod tests { "http://localhost:{}{}/{QUERY_ID}/input", addr.to_ip().unwrap().port(), http_serde::query::BASE_AXUM_PATH, - ) - .parse() - .unwrap(); + ); let req = http_serde::query::input::Request::new(QueryInput::FromUrl { query_id: QUERY_ID, url,