Skip to content

Commit

Permalink
fix(http client): set reuseaddr and nodelay. (#687)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
niklasad1 authored Mar 29, 2022
1 parent 054c0e3 commit 3f13274
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 17 additions & 9 deletions client/http-client/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
_ => {
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions proc-macros/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
_ => {}
}
}
Expand Down

0 comments on commit 3f13274

Please sign in to comment.