Fix retrieval of multi-subs

This commit is contained in:
Matthew Esposito 2024-05-29 18:36:56 -04:00
parent 27f25e0fb1
commit 273d889f1b

View File

@ -170,7 +170,7 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
// Construct the hyper client from the HTTPS connector.
let client: Client<_, Body> = CLIENT.clone();
let (token, vendor_id, device_id, user_agent, loid) = {
let (token, vendor_id, device_id, mut user_agent, loid) = {
let client = block_on(OAUTH_CLIENT.read());
(
client.token.clone(),
@ -180,6 +180,12 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
client.headers_map.get("x-reddit-loid").cloned().unwrap_or_default(),
)
};
// Check if multi sub requested. If so, replace "Android" with a tricky word.
if path.contains("+") {
user_agent = user_agent.replace("Android", "Android");
}
// Build request to Reddit. When making a GET, request gzip compression.
// (Reddit doesn't do brotli yet.)
let builder = Request::builder()