fix(updater): don't override user provided headers

pull/2621/head
Tony 3 months ago
parent c698e72594
commit 1372bf331f
No known key found for this signature in database
GPG Key ID: 34BDD3EA27824956

@ -17,7 +17,7 @@ use std::ffi::OsStr;
use base64::Engine; use base64::Engine;
use futures_util::StreamExt; use futures_util::StreamExt;
use http::HeaderName; use http::{header::ACCEPT, HeaderName};
use minisign_verify::{PublicKey, Signature}; use minisign_verify::{PublicKey, Signature};
use percent_encoding::{AsciiSet, CONTROLS}; use percent_encoding::{AsciiSet, CONTROLS};
use reqwest::{ use reqwest::{
@ -345,7 +345,9 @@ impl Updater {
pub async fn check(&self) -> Result<Option<Update>> { pub async fn check(&self) -> Result<Option<Update>> {
// we want JSON only // we want JSON only
let mut headers = self.headers.clone(); let mut headers = self.headers.clone();
headers.insert("Accept", HeaderValue::from_str("application/json").unwrap()); if !headers.contains_key(ACCEPT) {
headers.insert(ACCEPT, HeaderValue::from_static("application/json"));
}
// Set SSL certs for linux if they aren't available. // Set SSL certs for linux if they aren't available.
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@ -549,10 +551,9 @@ impl Update {
) -> Result<Vec<u8>> { ) -> Result<Vec<u8>> {
// set our headers // set our headers
let mut headers = self.headers.clone(); let mut headers = self.headers.clone();
headers.insert( if !headers.contains_key(ACCEPT) {
"Accept", headers.insert(ACCEPT, HeaderValue::from_static("application/octet-stream"));
HeaderValue::from_str("application/octet-stream").unwrap(), }
);
let mut request = ClientBuilder::new().user_agent(UPDATER_USER_AGENT); let mut request = ClientBuilder::new().user_agent(UPDATER_USER_AGENT);
if let Some(timeout) = self.timeout { if let Some(timeout) = self.timeout {

Loading…
Cancel
Save