From 7d2c47f3d4cabf3bef127c8cae406751192a5af9 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 1 Jan 2024 07:47:26 -0500 Subject: [PATCH] Add a 60 second keep-alive to connections --- common/request/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/request/src/lib.rs b/common/request/src/lib.rs index 63fb7c8d..2c56db94 100644 --- a/common/request/src/lib.rs +++ b/common/request/src/lib.rs @@ -49,11 +49,14 @@ pub struct Client { impl Client { fn connector() -> Connector { + let mut res = HttpConnector::new(); + res.set_keepalive(Some(core::time::Duration::from_secs(60))); #[cfg(feature = "tls")] - let res = - HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build(); - #[cfg(not(feature = "tls"))] - let res = HttpConnector::new(); + let res = HttpsConnectorBuilder::new() + .with_native_roots() + .https_or_http() + .enable_http1() + .wrap_connector(res); res }