Add tcp_keepalive option for ClientBuilder (#1070)
This commit is contained in:
committed by
GitHub
parent
6705b90a15
commit
00fb43b650
@@ -71,6 +71,7 @@ impl_http_connector! {
|
||||
fn set_local_address(&mut self, addr: Option<IpAddr>);
|
||||
fn enforce_http(&mut self, is_enforced: bool);
|
||||
fn set_nodelay(&mut self, nodelay: bool);
|
||||
fn set_keepalive(&mut self, dur: Option<Duration>);
|
||||
}
|
||||
|
||||
impl Service<Uri> for HttpConnector {
|
||||
@@ -474,6 +475,17 @@ impl Connector {
|
||||
|
||||
self.connect_with_maybe_proxy(proxy_dst, true).await
|
||||
}
|
||||
|
||||
pub fn set_keepalive(&mut self, dur: Option<Duration>) {
|
||||
match &mut self.inner {
|
||||
#[cfg(feature = "default-tls")]
|
||||
Inner::DefaultTls(http, _tls) => http.set_keepalive(dur),
|
||||
#[cfg(feature = "rustls-tls")]
|
||||
Inner::RustlsTls { http, .. } => http.set_keepalive(dur),
|
||||
#[cfg(not(feature = "__tls"))]
|
||||
Inner::Http(http) => http.set_keepalive(dur),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn into_uri(scheme: Scheme, host: Authority) -> Uri {
|
||||
|
||||
Reference in New Issue
Block a user