Unverified Commit 3f13274b authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

fix(http client): set reuseaddr and nodelay. (#687)

* fix(http client): set reuseaddr and nodelay.

* configure socket for https too

* http server: `set_reuse_port`

* fix windows build

* revert http server changes

* fix build with latest syn
parent 054c0e39
Pipeline #185906 passed with stages
in 4 minutes and 33 seconds
......@@ -57,24 +57,32 @@ 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 connector = HttpConnector::new();
let client = Client::builder().build::<_, hyper::Body>(connector);
HyperClient::Http(client)
}
#[cfg(feature = "tls")]
Some("https") => {
let connector = match cert_store {
CertificateStore::Native => {
hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1()
}
CertificateStore::WebPki => {
hyper_rustls::HttpsConnectorBuilder::new().with_webpki_roots().https_or_http().enable_http1()
}
CertificateStore::Native => hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.wrap_connector(connector),
CertificateStore::WebPki => hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_or_http()
.enable_http1()
.wrap_connector(connector),
_ => return Err(Error::InvalidCertficateStore),
};
let client = Client::builder().build::<_, hyper::Body>(connector.build());
let client = Client::builder().build::<_, hyper::Body>(connector);
HyperClient::Https(client)
}
_ => {
......@@ -132,7 +140,7 @@ pub enum Error {
Url(String),
/// Error during the HTTP request, including networking errors and HTTP protocol errors.
#[error("Error while performing the HTTP request")]
#[error("HTTP error: {0}")]
Http(Box<dyn std::error::Error + Send + Sync>),
/// Server returned a non-success status code.
......
......@@ -168,9 +168,7 @@ impl FindSubscriptionParams {
syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {}
#[cfg(test)]
syn::Type::__TestExhaustive(_) => unimplemented!(),
#[cfg(not(test))]
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {}
}
}
......
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