From 10d7919adfaabc333faafe2ad6a64a9e38a2a8db Mon Sep 17 00:00:00 2001 From: lostb1t Date: Fri, 26 Jul 2024 18:46:46 +0200 Subject: [PATCH] fix: fallback for --- src/plex_client.rs | 11 ++++++----- src/routes.rs | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/plex_client.rs b/src/plex_client.rs index 3a340e4..cc2cf50 100644 --- a/src/plex_client.rs +++ b/src/plex_client.rs @@ -91,7 +91,7 @@ impl PlexClient { ); let mut headers = self.default_headers.clone(); for (key, value) in req.headers().iter() { - if key != ACCEPT { + if key != ACCEPT && key != http::header::HOST { headers.insert(key, value.clone()); } } @@ -123,8 +123,8 @@ impl PlexClient { //dbg!(&url); //dbg!(&req.uri().clone().query().unwrap().to_string()); let mut headers = req.headers().clone(); - //headers.remove(ACCEPT); // remove accept as we always do json request - + headers.remove(ACCEPT); // remove accept as we always do json request + headers.remove(http::header::HOST); let res = self .http_client .request(req.method().clone(), url) @@ -448,8 +448,9 @@ impl PlexClient { ("X-Plex-Client-Capabilities", context.client_capabilities.clone()), ("X-Forwarded-For", context.forwarded_for.clone()), ("X-Real-Ip", context.real_ip.clone()), - ("ACCEPT", Some("application/json".to_string())), - ("ACCEPT_LANGUAGE", Some("en-US".to_string())), + (&ACCEPT.as_str(), Some("application/json".to_string())), + (&ACCEPT_LANGUAGE.as_str(), Some("en-US".to_string())), + (http::header::HOST.as_str(), Some(config.host.clone().unwrap())), ]); for (key, val) in headers_map { diff --git a/src/routes.rs b/src/routes.rs index 4dfef6f..97202d7 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -992,10 +992,10 @@ async fn get_transcoding_for_request( let mut depot = &mut Depot::new(); let mut ctrl = &mut FlowCtrl::new(vec![]); proxy_for_transform.handle(req, depot, res, ctrl).await; - //dbg!(&res_upstream); + dbg!(&res); - //let res = plex_client.proxy_request(&req).await?; - //dbg!(&res); + let ress = plex_client.proxy_request(&req).await?; + dbg!(&ress); //dbg!(&req); let transcode: MediaContainerWrapper =