From efdf1848ac8debea002854ed424b49630b32986e Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Thu, 31 Oct 2024 16:06:29 -0400 Subject: [PATCH] fix: emergency patch for 403 --- src/client.rs | 10 ++++++++-- src/oauth.rs | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index ba1ff8cc..cd6fe694 100644 --- a/src/client.rs +++ b/src/client.rs @@ -154,7 +154,10 @@ async fn stream(url: &str, req: &Request) -> Result, String let parsed_uri = url.parse::().map_err(|_| "Couldn't parse URL".to_string())?; // Build the hyper client from the HTTPS connector. - let client: Client<_, Body> = CLIENT.clone(); + let client: Client<_, Body> = { + let https = hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_only().enable_http1().build(); + client::Client::builder().pool_max_idle_per_host(0).build(https) + }; let mut builder = Request::get(parsed_uri); @@ -216,7 +219,10 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo let url = format!("{base_path}{path}"); // Construct the hyper client from the HTTPS connector. - let client: Client<_, Body> = CLIENT.clone(); + let client: Client<_, Body> = { + let https = hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_only().enable_http1().build(); + client::Client::builder().pool_max_idle_per_host(0).build(https) + }; let (token, vendor_id, device_id, user_agent, loid) = { let client = OAUTH_CLIENT.load_full(); diff --git a/src/oauth.rs b/src/oauth.rs index 48a37fb1..03520a9f 100644 --- a/src/oauth.rs +++ b/src/oauth.rs @@ -94,7 +94,10 @@ impl Oauth { trace!("Sending token request..."); // Send request - let client: client::Client<_, Body> = CLIENT.clone(); + let client: client::Client<_, Body> = { + let https = hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_only().enable_http1().build(); + client::Client::builder().pool_max_idle_per_host(0).build(https) + }; let resp = client.request(request).await.ok()?; trace!("Received response with status {} and length {:?}", resp.status(), resp.headers().get("content-length"));