File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 3
3
use std:: net:: SocketAddr ;
4
4
5
5
use bytes:: Bytes ;
6
+ use http:: { uri, Uri } ;
6
7
use http_body_util:: { combinators:: BoxBody , BodyExt , Empty , Full } ;
7
8
use hyper:: client:: conn:: http1:: Builder ;
8
9
use hyper:: server:: conn:: http1;
@@ -49,7 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
49
50
}
50
51
51
52
async fn proxy (
52
- req : Request < hyper:: body:: Incoming > ,
53
+ mut req : Request < hyper:: body:: Incoming > ,
53
54
) -> Result < Response < BoxBody < Bytes , hyper:: Error > > , hyper:: Error > {
54
55
println ! ( "req: {:?}" , req) ;
55
56
@@ -105,6 +106,10 @@ async fn proxy(
105
106
}
106
107
} ) ;
107
108
109
+ let mut uri_parts = uri:: Parts :: default ( ) ;
110
+ uri_parts. path_and_query = req. uri ( ) . path_and_query ( ) . cloned ( ) ;
111
+ * req. uri_mut ( ) = Uri :: from_parts ( uri_parts) . unwrap ( ) ;
112
+
108
113
let resp = sender. send_request ( req) . await ?;
109
114
Ok ( resp. map ( |b| b. boxed ( ) ) )
110
115
}
You can’t perform that action at this time.
0 commit comments