Skip to content

Commit

Permalink
fix(client): update headers
Browse files Browse the repository at this point in the history
  • Loading branch information
sigaloid committed Nov 19, 2024
1 parent 0bc36d5 commit 18efb8c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down

0 comments on commit 18efb8c

Please sign in to comment.