Skip to content

Commit

Permalink
Update funcation args
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 committed Aug 13, 2024
1 parent 2d7b181 commit 73ce83b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
9 changes: 3 additions & 6 deletions examples/pre_configured_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ async fn main() -> Result<(), Box<dyn Error>> {

// Build a client with pre-configured TLS settings
let client = rquest::Client::builder()
.use_preconfigured_tls(
|| settings,
|headers| {
headers.insert("user-agent", HeaderValue::from_static("rquest"));
},
)
.use_preconfigured_tls(settings, |headers| {
headers.insert("user-agent", HeaderValue::from_static("rquest"));
})
.enable_ech_grease()
.permute_extensions()
.build()?;
Expand Down
7 changes: 3 additions & 4 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,11 @@ impl ClientBuilder {

/// Use the preconfigured TLS settings.
#[cfg(feature = "boring-tls")]
pub fn use_preconfigured_tls<F1, F2>(self, f1: F1, f2: F2) -> ClientBuilder
pub fn use_preconfigured_tls<F>(self, settings: TlsSettings, func: F) -> ClientBuilder
where
F1: FnOnce() -> TlsSettings,
F2: FnOnce(&mut HeaderMap),
F: FnOnce(&mut HeaderMap),
{
self.apply_tls_settings(f1(), f2)
self.apply_tls_settings(settings, func)
}

/// Apply the given TLS settings and header function.
Expand Down
7 changes: 3 additions & 4 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ impl ClientBuilder {

/// Use the preconfigured TLS settings.
#[cfg(feature = "boring-tls")]
pub fn use_preconfigured_tls<F1, F2>(self, f1: F1, f2: F2) -> ClientBuilder
pub fn use_preconfigured_tls<F>(self, settings: TlsSettings, func: F) -> ClientBuilder
where
F1: FnOnce() -> TlsSettings,
F2: FnOnce(&mut HeaderMap),
F: FnOnce(&mut HeaderMap),
{
self.with_inner(move |inner| inner.use_preconfigured_tls(f))
self.with_inner(move |inner| inner.use_preconfigured_tls(settings, func))
}

/// Enable Encrypted Client Hello (Secure SNI)
Expand Down

0 comments on commit 73ce83b

Please sign in to comment.