From ac949126d1296da0922742a4f216b1bab7667b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Fri, 7 Apr 2023 20:04:28 +0200 Subject: [PATCH] Use Firefox user-agent header and add some additional headers (fixes #318) --- native/src/utils.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/native/src/utils.rs b/native/src/utils.rs index 02d3e6a3..410b7865 100644 --- a/native/src/utils.rs +++ b/native/src/utils.rs @@ -5,12 +5,11 @@ use std::path::PathBuf; use anyhow::{Context, Result}; use log::warn; use reqwest::blocking::Client; +use reqwest::header::{HeaderMap, HeaderValue}; use reqwest::Certificate; -const APP_USER_AGENT: &str = concat!( - "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0 PWAsForFirefox/", - env!("CARGO_PKG_VERSION") -); +const APP_USER_AGENT: &str = + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"; /// Load DER and PEM certificates from files. /// @@ -64,8 +63,13 @@ pub fn construct_client( danger_accept_invalid_certs: bool, danger_accept_invalid_hostnames: bool, ) -> reqwest::Result { + let mut headers = HeaderMap::new(); + headers.insert("Sec-Fetch-Site", HeaderValue::from_static("none")); + headers.insert("Sec-Fetch-Dest", HeaderValue::from_static("manifest")); + let mut builder = Client::builder() .user_agent(APP_USER_AGENT) + .default_headers(headers) .danger_accept_invalid_certs(danger_accept_invalid_certs) .danger_accept_invalid_hostnames(danger_accept_invalid_hostnames);