Skip to content

Commit 5e32392

Browse files
Legend-Mastergezihuzi
authored andcommitted
fix(updater): don't override user provided headers (tauri-apps#2621)
1 parent 4ba538d commit 5e32392

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
updater: patch
3+
updater-js: patch
4+
---
5+
6+
Fix `check` and `download` overrides the `accept` header

plugins/updater/src/updater.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::ffi::OsStr;
1717

1818
use base64::Engine;
1919
use futures_util::StreamExt;
20-
use http::HeaderName;
20+
use http::{header::ACCEPT, HeaderName};
2121
use minisign_verify::{PublicKey, Signature};
2222
use percent_encoding::{AsciiSet, CONTROLS};
2323
use reqwest::{
@@ -345,7 +345,9 @@ impl Updater {
345345
pub async fn check(&self) -> Result<Option<Update>> {
346346
// we want JSON only
347347
let mut headers = self.headers.clone();
348-
headers.insert("Accept", HeaderValue::from_str("application/json").unwrap());
348+
if !headers.contains_key(ACCEPT) {
349+
headers.insert(ACCEPT, HeaderValue::from_static("application/json"));
350+
}
349351

350352
// Set SSL certs for linux if they aren't available.
351353
#[cfg(target_os = "linux")]
@@ -549,10 +551,9 @@ impl Update {
549551
) -> Result<Vec<u8>> {
550552
// set our headers
551553
let mut headers = self.headers.clone();
552-
headers.insert(
553-
"Accept",
554-
HeaderValue::from_str("application/octet-stream").unwrap(),
555-
);
554+
if !headers.contains_key(ACCEPT) {
555+
headers.insert(ACCEPT, HeaderValue::from_static("application/octet-stream"));
556+
}
556557

557558
let mut request = ClientBuilder::new().user_agent(UPDATER_USER_AGENT);
558559
if let Some(timeout) = self.timeout {

0 commit comments

Comments
 (0)