diff options
author | Luca Casonato <luca.casonato@antipy.com> | 2020-07-18 21:05:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-18 15:05:08 -0400 |
commit | 071a6e284aaaa26d40300b82d9f4cbb15a4dd6f5 (patch) | |
tree | ec66978303cb4b755366bbaab7028f9a3f455956 /cli/state.rs | |
parent | da48fa42d309e32684210a8d30ec3fc7ef7079df (diff) |
Share reqwest client between fetch calls (#6792)
Diffstat (limited to 'cli/state.rs')
-rw-r--r-- | cli/state.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cli/state.rs b/cli/state.rs index aa78f5c1a..f04b577b4 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -2,6 +2,7 @@ use crate::file_fetcher::SourceFileFetcher; use crate::global_state::GlobalState; use crate::global_timer::GlobalTimer; +use crate::http_util::create_http_client; use crate::import_map::ImportMap; use crate::metrics::Metrics; use crate::op_error::OpError; @@ -61,6 +62,7 @@ pub struct StateInner { pub target_lib: TargetLib, pub is_main: bool, pub is_internal: bool, + pub http_client: reqwest::Client, } impl State { @@ -338,6 +340,8 @@ impl State { global_state.permissions.clone() }; + let http_client = create_http_client(global_state.flags.ca_file.clone())?; + let state = Rc::new(RefCell::new(StateInner { global_state, main_module, @@ -352,6 +356,7 @@ impl State { target_lib: TargetLib::Main, is_main: true, is_internal, + http_client, })); Ok(Self(state)) @@ -374,6 +379,8 @@ impl State { global_state.permissions.clone() }; + let http_client = create_http_client(global_state.flags.ca_file.clone())?; + let state = Rc::new(RefCell::new(StateInner { global_state, main_module, @@ -388,6 +395,7 @@ impl State { target_lib: TargetLib::Worker, is_main: false, is_internal: false, + http_client, })); Ok(Self(state)) |