Skip to content
This repository has been archived by the owner on Jan 16, 2025. It is now read-only.

Commit

Permalink
fix(client): Optional setting of default accept (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 authored Sep 6, 2024
1 parent 6ac4a0b commit fc4df7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,14 @@ impl ClientBuilder {
self
}

/// Default accpet
pub fn default_accpet(mut self) -> ClientBuilder {
self.config
.headers
.insert(ACCEPT, HeaderValue::from_static("*/*"));
self
}

/// Enable a persistent cookie store for the client.
///
/// Cookies received in responses will be preserved and included in
Expand Down Expand Up @@ -1349,22 +1357,14 @@ impl Client {
return Pending::new_err(error::url_bad_scheme(url));
}

let mut accept = false;

// insert default headers in the request headers
// without overwriting already appended headers.
for (key, value) in &self.inner.headers {
if let Entry::Vacant(entry) = headers.entry(key) {
accept = ACCEPT.eq(key);
entry.insert(value.clone());
}
}

// Default accpet
if accept || headers.is_empty() {
headers.insert(ACCEPT, HeaderValue::from_static("*/*"));
}

// Add cookies from the cookie store.
#[cfg(feature = "cookies")]
{
Expand Down
2 changes: 1 addition & 1 deletion src/tls/impersonate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn tls_settings(ver: Impersonate) -> TlsResult<(TlsSettings, Box<dyn FnOnce(
Chrome124 => v124::get_settings,
Chrome126 => v126::get_settings,
Chrome127 => v127::get_settings,
Chrome128 => v128::get_settings,
Chrome128 => v128::get_settings,

// Safari
SafariIos17_2 => safari_ios_17_2::get_settings,
Expand Down

0 comments on commit fc4df7c

Please sign in to comment.