Unverified Commit 661870a0 authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

fix(http client): use https connector for https (#750)

* fix: use https conn for https

* enable integration tests for https and wss

* remove socket options of http client
parent 8e945de4
Pipeline #191624 passed with stages
in 6 minutes and 3 seconds
......@@ -57,16 +57,8 @@ 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 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 {
......@@ -74,16 +66,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")]
......
......@@ -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");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment