Upstream client to always use HTTP/2 and HTTPS

This commit is contained in:
Edward Shen 2021-06-06 18:51:05 -04:00
parent 97ea5eb448
commit 2501bb8da0
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -1,4 +1,5 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::time::Duration;
use actix_web::error::ErrorNotFound; use actix_web::error::ErrorNotFound;
use actix_web::http::header::{ 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); pub const BASE64_CONFIG: base64::Config = base64::Config::new(base64::CharacterSet::UrlSafe, false);
static HTTP_CLIENT: Lazy<Client> = Lazy::new(Client::new); static HTTP_CLIENT: Lazy<Client> = 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!( const SERVER_ID_STRING: &str = concat!(
env!("CARGO_CRATE_NAME"), env!("CARGO_CRATE_NAME"),