Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/updater-override-header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
updater: patch
updater-js: patch
---

Fix `check` and `download` overrides the `accept` header
13 changes: 7 additions & 6 deletions plugins/updater/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::ffi::OsStr;

use base64::Engine;
use futures_util::StreamExt;
use http::HeaderName;
use http::{header::ACCEPT, HeaderName};
use minisign_verify::{PublicKey, Signature};
use percent_encoding::{AsciiSet, CONTROLS};
use reqwest::{
Expand Down Expand Up @@ -345,7 +345,9 @@ impl Updater {
pub async fn check(&self) -> Result<Option<Update>> {
// we want JSON only
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.
#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -549,10 +551,9 @@ impl Update {
) -> Result<Vec<u8>> {
// set our headers
let mut headers = self.headers.clone();
headers.insert(
"Accept",
HeaderValue::from_str("application/octet-stream").unwrap(),
);
if !headers.contains_key(ACCEPT) {
headers.insert(ACCEPT, HeaderValue::from_static("application/octet-stream"));
}

let mut request = ClientBuilder::new().user_agent(UPDATER_USER_AGENT);
if let Some(timeout) = self.timeout {
Expand Down
Loading