File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,13 @@ async fn fetch_url(url: hyper::Uri) -> Result<()> {
46
46
}
47
47
} ) ;
48
48
49
- let req = Request :: builder ( ) . uri ( url) . body ( Body :: empty ( ) ) . unwrap ( ) ;
49
+ let authority = url. authority ( ) . unwrap ( ) . clone ( ) ;
50
+
51
+ let req = Request :: builder ( )
52
+ . uri ( url)
53
+ . header ( hyper:: header:: HOST , authority. as_str ( ) )
54
+ . body ( Body :: empty ( ) ) ?;
55
+
50
56
let mut res = sender. send_request ( req) . await ?;
51
57
52
58
println ! ( "Response: {}" , res. status( ) ) ;
Original file line number Diff line number Diff line change @@ -36,8 +36,14 @@ async fn fetch_json(url: hyper::Uri) -> Result<Vec<User>> {
36
36
}
37
37
} ) ;
38
38
39
+ let authority = url. authority ( ) . unwrap ( ) . clone ( ) ;
40
+
39
41
// Fetch the url...
40
- let req = Request :: builder ( ) . uri ( url) . body ( Body :: empty ( ) ) . unwrap ( ) ;
42
+ let req = Request :: builder ( )
43
+ . uri ( url)
44
+ . header ( hyper:: header:: HOST , authority. as_str ( ) )
45
+ . body ( Body :: empty ( ) ) ?;
46
+
41
47
let res = sender. send_request ( req) . await ?;
42
48
43
49
// asynchronously aggregate the chunks of the body
You can’t perform that action at this time.
0 commit comments