From 2501bb8da0889117394f28195fd9d713f1690f53 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Sun, 6 Jun 2021 18:51:05 -0400 Subject: [PATCH] Upstream client to always use HTTP/2 and HTTPS --- src/routes.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/routes.rs b/src/routes.rs index e13f252..ad8794f 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -1,4 +1,5 @@ use std::sync::atomic::Ordering; +use std::time::Duration; use actix_web::error::ErrorNotFound; use actix_web::http::header::{ @@ -31,7 +32,14 @@ use crate::state::RwLockServerState; pub const BASE64_CONFIG: base64::Config = base64::Config::new(base64::CharacterSet::UrlSafe, false); -static HTTP_CLIENT: Lazy = Lazy::new(Client::new); +static HTTP_CLIENT: Lazy = Lazy::new(|| { + Client::builder() + .pool_idle_timeout(Duration::from_secs(180)) + .https_only(true) + .http2_prior_knowledge() + .build() + .expect("Client initialization to work") +}); const SERVER_ID_STRING: &str = concat!( env!("CARGO_CRATE_NAME"),