File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,14 @@ impl Clone for H1Client {
32
32
impl HttpClient for H1Client {
33
33
type Error = Error ;
34
34
35
- fn send ( & self , req : Request ) -> BoxFuture < ' static , Result < Response , Self :: Error > > {
35
+ fn send ( & self , mut req : Request ) -> BoxFuture < ' static , Result < Response , Self :: Error > > {
36
36
Box :: pin ( async move {
37
37
// Insert host
38
38
let host = req
39
39
. url ( )
40
40
. host_str ( )
41
- . ok_or_else ( || Error :: from_str ( StatusCode :: BadRequest , "missing hostname" ) ) ?;
41
+ . ok_or_else ( || Error :: from_str ( StatusCode :: BadRequest , "missing hostname" ) ) ?
42
+ . to_string ( ) ;
42
43
43
44
let scheme = req. url ( ) . scheme ( ) ;
44
45
if scheme != "http" && scheme != "https" {
@@ -64,10 +65,14 @@ impl HttpClient for H1Client {
64
65
match scheme {
65
66
"http" => {
66
67
let stream = async_std:: net:: TcpStream :: connect ( addr) . await ?;
68
+ req. set_peer_addr ( stream. peer_addr ( ) . ok ( ) ) ;
69
+ req. set_local_addr ( stream. local_addr ( ) . ok ( ) ) ;
67
70
client:: connect ( stream, req) . await
68
71
}
69
72
"https" => {
70
73
let raw_stream = async_std:: net:: TcpStream :: connect ( addr) . await ?;
74
+ req. set_peer_addr ( raw_stream. peer_addr ( ) . ok ( ) ) ;
75
+ req. set_local_addr ( raw_stream. local_addr ( ) . ok ( ) ) ;
71
76
72
77
let stream = async_native_tls:: connect ( host, raw_stream) . await ?;
73
78
You can’t perform that action at this time.
0 commit comments