From 18efb8c714ad10e0082059e1d47e0f95686d04a7 Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Tue, 19 Nov 2024 14:10:59 -0500 Subject: [PATCH] fix(client): update headers --- src/client.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.rs b/src/client.rs index 978214e..f13e864 100644 --- a/src/client.rs +++ b/src/client.rs @@ -229,6 +229,12 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo ) }; + let (key, value) = match fastrand::u32(0..3) { + 0 => ("X-Reddit-Width", fastrand::u32(300..500).to_string()), + 1 => ("X-Reddit-DPR", "2".to_owned()), + _ => ("Device-Name", format!("Android {}", fastrand::u8(9..=14))), + }; + // Build request to Reddit. When making a GET, request gzip compression. // (Reddit doesn't do brotli yet.) let builder = Request::builder() @@ -241,6 +247,7 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo .header("Host", host) .header("Authorization", &format!("Bearer {token}")) .header("Accept-Encoding", if method == Method::GET { "gzip" } else { "identity" }) + .header(key, value) .header( "Cookie", if quarantine {