summaryrefslogtreecommitdiff
path: root/ext/fetch/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fetch/lib.rs')
-rw-r--r--ext/fetch/lib.rs38
1 files changed, 22 insertions, 16 deletions
diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs
index e384a918e..3e43370d3 100644
--- a/ext/fetch/lib.rs
+++ b/ext/fetch/lib.rs
@@ -187,27 +187,33 @@ pub fn get_or_create_client_from_state(
Ok(client.clone())
} else {
let options = state.borrow::<Options>();
- let client = create_http_client(
- &options.user_agent,
- CreateHttpClientOptions {
- root_cert_store: options.root_cert_store()?,
- ca_certs: vec![],
- proxy: options.proxy.clone(),
- unsafely_ignore_certificate_errors: options
- .unsafely_ignore_certificate_errors
- .clone(),
- client_cert_chain_and_key: options.client_cert_chain_and_key.clone(),
- pool_max_idle_per_host: None,
- pool_idle_timeout: None,
- http1: true,
- http2: true,
- },
- )?;
+ let client = create_client_from_options(options)?;
state.put::<reqwest::Client>(client.clone());
Ok(client)
}
}
+pub fn create_client_from_options(
+ options: &Options,
+) -> Result<reqwest::Client, AnyError> {
+ create_http_client(
+ &options.user_agent,
+ CreateHttpClientOptions {
+ root_cert_store: options.root_cert_store()?,
+ ca_certs: vec![],
+ proxy: options.proxy.clone(),
+ unsafely_ignore_certificate_errors: options
+ .unsafely_ignore_certificate_errors
+ .clone(),
+ client_cert_chain_and_key: options.client_cert_chain_and_key.clone(),
+ pool_max_idle_per_host: None,
+ pool_idle_timeout: None,
+ http1: true,
+ http2: true,
+ },
+ )
+}
+
#[allow(clippy::type_complexity)]
pub struct ResourceToBodyAdapter(
Rc<dyn Resource>,