From cc31042fd0b7f51601d19df95e6ee70d5eab3765 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Sat, 30 Apr 2022 09:46:59 +0200 Subject: [PATCH 1/3] fix: use https conn for https --- client/http-client/src/transport.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/http-client/src/transport.rs b/client/http-client/src/transport.rs index f1804dc7aa..b00921f437 100644 --- a/client/http-client/src/transport.rs +++ b/client/http-client/src/transport.rs @@ -57,13 +57,13 @@ impl HttpTransportClient { return Err(Error::Url("Port number is missing in the URL".into())); } - let mut connector = HttpConnector::new(); - - connector.set_reuse_address(true); - connector.set_nodelay(true); - let client = match target.scheme_str() { Some("http") => { + let mut connector = HttpConnector::new(); + + connector.set_reuse_address(true); + connector.set_nodelay(true); + let client = Client::builder().build::<_, hyper::Body>(connector); HyperClient::Http(client) } @@ -74,16 +74,15 @@ impl HttpTransportClient { .with_native_roots() .https_or_http() .enable_http1() - .wrap_connector(connector), + .build(), CertificateStore::WebPki => hyper_rustls::HttpsConnectorBuilder::new() .with_webpki_roots() .https_or_http() .enable_http1() - .wrap_connector(connector), + .build(), _ => return Err(Error::InvalidCertficateStore), }; - let client = Client::builder().build::<_, hyper::Body>(connector); - HyperClient::Https(client) + HyperClient::Https(Client::builder().build::<_, hyper::Body>(connector)) } _ => { #[cfg(feature = "tls")] From da579d95ca35eec8be7bf25868b327aaf72c8c6b Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Sat, 30 Apr 2022 10:03:45 +0200 Subject: [PATCH 2/3] enable integration tests for https and wss --- tests/tests/integration_tests.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/tests/integration_tests.rs b/tests/tests/integration_tests.rs index 381b00cd50..5c4b734b84 100644 --- a/tests/tests/integration_tests.rs +++ b/tests/tests/integration_tests.rs @@ -251,17 +251,15 @@ async fn http_making_more_requests_than_allowed_should_not_deadlock() { } #[tokio::test] -#[ignore] async fn https_works() { - let client = HttpClientBuilder::default().build("https://kusama-rpc.polkadot.io").unwrap(); + let client = HttpClientBuilder::default().build("https://kusama-rpc.polkadot.io:443").unwrap(); let response: String = client.request("system_chain", None).await.unwrap(); assert_eq!(&response, "Kusama"); } #[tokio::test] -#[ignore] async fn wss_works() { - let client = WsClientBuilder::default().build("wss://kusama-rpc.polkadot.io").await.unwrap(); + let client = WsClientBuilder::default().build("wss://kusama-rpc.polkadot.io:443").await.unwrap(); let response: String = client.request("system_chain", None).await.unwrap(); assert_eq!(&response, "Kusama"); } From 5457bde63d6cbdcb9dba7a69e572226517db0b13 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 3 May 2022 12:16:44 +0200 Subject: [PATCH 3/3] remove socket options of http client --- client/http-client/src/transport.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/client/http-client/src/transport.rs b/client/http-client/src/transport.rs index b00921f437..81868e25a6 100644 --- a/client/http-client/src/transport.rs +++ b/client/http-client/src/transport.rs @@ -58,15 +58,7 @@ impl HttpTransportClient { } let client = match target.scheme_str() { - Some("http") => { - let mut connector = HttpConnector::new(); - - connector.set_reuse_address(true); - connector.set_nodelay(true); - - let client = Client::builder().build::<_, hyper::Body>(connector); - HyperClient::Http(client) - } + Some("http") => HyperClient::Http(Client::new()), #[cfg(feature = "tls")] Some("https") => { let connector = match cert_store {