diff --git a/examples/client.rs b/examples/client.rs index a64c35273b..be3de681e5 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -53,12 +53,10 @@ async fn fetch_url(url: hyper::Uri) -> Result<()> { } }); - let authority = url.authority().unwrap().clone(); - let path = url.path(); let req = Request::builder() .uri(path) - .header(hyper::header::HOST, authority.as_str()) + .header(hyper::header::HOST, format!("{}:{}", host, port)) .body(Empty::::new())?; let mut res = sender.send_request(req).await?; diff --git a/examples/client_json.rs b/examples/client_json.rs index 6a6753528c..07582a62d9 100644 --- a/examples/client_json.rs +++ b/examples/client_json.rs @@ -42,12 +42,10 @@ async fn fetch_json(url: hyper::Uri) -> Result> { } }); - let authority = url.authority().unwrap().clone(); - - // Fetch the url... + // Fetch the URL... let req = Request::builder() .uri(url) - .header(hyper::header::HOST, authority.as_str()) + .header(hyper::header::HOST, format!("{}:{}", host, port)) .body(Empty::::new())?; let res = sender.send_request(req).await?; diff --git a/examples/single_threaded.rs b/examples/single_threaded.rs index f297814c92..eec67c0cab 100644 --- a/examples/single_threaded.rs +++ b/examples/single_threaded.rs @@ -181,13 +181,11 @@ async fn http1_client(url: hyper::Uri) -> Result<(), Box> } }); - let authority = url.authority().unwrap().clone(); - // Make 4 requests for _ in 0..4 { let req = Request::builder() .uri(url.clone()) - .header(hyper::header::HOST, authority.as_str()) + .header(hyper::header::HOST, format!("{}:{}", host, port)) .body(Body::from("test".to_string()))?; let mut res = sender.send_request(req).await?; @@ -282,13 +280,11 @@ async fn http2_client(url: hyper::Uri) -> Result<(), Box> } }); - let authority = url.authority().unwrap().clone(); - // Make 4 requests for _ in 0..4 { let req = Request::builder() .uri(url.clone()) - .header(hyper::header::HOST, authority.as_str()) + .header(hyper::header::HOST, format!("{}:{}", host, port)) .body(Body::from("test".to_string()))?; let mut res = sender.send_request(req).await?;