fix(client): update headers

This commit is contained in:
Matthew Esposito 2024-11-19 14:10:59 -05:00
parent 0bc36d529c
commit 18efb8c714

View File

@ -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. // Build request to Reddit. When making a GET, request gzip compression.
// (Reddit doesn't do brotli yet.) // (Reddit doesn't do brotli yet.)
let builder = Request::builder() let builder = Request::builder()
@ -241,6 +247,7 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
.header("Host", host) .header("Host", host)
.header("Authorization", &format!("Bearer {token}")) .header("Authorization", &format!("Bearer {token}"))
.header("Accept-Encoding", if method == Method::GET { "gzip" } else { "identity" }) .header("Accept-Encoding", if method == Method::GET { "gzip" } else { "identity" })
.header(key, value)
.header( .header(
"Cookie", "Cookie",
if quarantine { if quarantine {