diff --git a/examples/http_proxy.rs b/examples/http_proxy.rs index 2dbc5c9ac7..7f981fc2a1 100644 --- a/examples/http_proxy.rs +++ b/examples/http_proxy.rs @@ -3,6 +3,7 @@ use std::net::SocketAddr; use bytes::Bytes; +use http::{uri, Uri}; use http_body_util::{combinators::BoxBody, BodyExt, Empty, Full}; use hyper::client::conn::http1::Builder; use hyper::server::conn::http1; @@ -49,7 +50,7 @@ async fn main() -> Result<(), Box> { } async fn proxy( - req: Request, + mut req: Request, ) -> Result>, hyper::Error> { println!("req: {:?}", req); @@ -105,6 +106,10 @@ async fn proxy( } }); + let mut uri_parts = uri::Parts::default(); + uri_parts.path_and_query = req.uri().path_and_query().cloned(); + *req.uri_mut() = Uri::from_parts(uri_parts).unwrap(); + let resp = sender.send_request(req).await?; Ok(resp.map(|b| b.boxed())) }