summaryrefslogtreecommitdiff
path: root/cli/npm
diff options
context:
space:
mode:
Diffstat (limited to 'cli/npm')
-rw-r--r--cli/npm/cache.rs7
-rw-r--r--cli/npm/registry.rs7
2 files changed, 10 insertions, 4 deletions
diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs
index 2ca597bd7..ce2208db7 100644
--- a/cli/npm/cache.rs
+++ b/cli/npm/cache.rs
@@ -10,11 +10,11 @@ use deno_core::anyhow::Context;
use deno_core::error::custom_error;
use deno_core::error::AnyError;
use deno_core::url::Url;
-use deno_runtime::deno_fetch::reqwest;
use crate::deno_dir::DenoDir;
use crate::file_fetcher::CacheSetting;
use crate::fs_util;
+use crate::http_util::HttpClient;
use crate::progress_bar::ProgressBar;
use super::registry::NpmPackageVersionDistInfo;
@@ -315,6 +315,7 @@ impl ReadonlyNpmCache {
pub struct NpmCache {
readonly: ReadonlyNpmCache,
cache_setting: CacheSetting,
+ http_client: HttpClient,
progress_bar: ProgressBar,
}
@@ -322,11 +323,13 @@ impl NpmCache {
pub fn from_deno_dir(
dir: &DenoDir,
cache_setting: CacheSetting,
+ http_client: HttpClient,
progress_bar: ProgressBar,
) -> Self {
Self {
readonly: ReadonlyNpmCache::from_deno_dir(dir),
cache_setting,
+ http_client,
progress_bar,
}
}
@@ -383,7 +386,7 @@ impl NpmCache {
}
let _guard = self.progress_bar.update(&dist.tarball);
- let response = reqwest::get(&dist.tarball).await?;
+ let response = self.http_client.get(&dist.tarball).send().await?;
if response.status() == 404 {
bail!("Could not find npm package tarball at: {}", dist.tarball);
diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs
index 066c136ee..3f0a84165 100644
--- a/cli/npm/registry.rs
+++ b/cli/npm/registry.rs
@@ -18,12 +18,12 @@ use deno_core::serde::Deserialize;
use deno_core::serde_json;
use deno_core::url::Url;
use deno_runtime::colors;
-use deno_runtime::deno_fetch::reqwest;
use serde::Serialize;
use crate::file_fetcher::CacheSetting;
use crate::fs_util;
use crate::http_cache::CACHE_PERM;
+use crate::http_util::HttpClient;
use crate::progress_bar::ProgressBar;
use super::cache::NpmCache;
@@ -249,6 +249,7 @@ impl RealNpmRegistryApi {
base_url: Url,
cache: NpmCache,
cache_setting: CacheSetting,
+ http_client: HttpClient,
progress_bar: ProgressBar,
) -> Self {
Self(Arc::new(RealNpmRegistryApiInner {
@@ -256,6 +257,7 @@ impl RealNpmRegistryApi {
cache,
mem_cache: Default::default(),
cache_setting,
+ http_client,
progress_bar,
}))
}
@@ -285,6 +287,7 @@ struct RealNpmRegistryApiInner {
cache: NpmCache,
mem_cache: Mutex<HashMap<String, Option<Arc<NpmPackageInfo>>>>,
cache_setting: CacheSetting,
+ http_client: HttpClient,
progress_bar: ProgressBar,
}
@@ -420,7 +423,7 @@ impl RealNpmRegistryApiInner {
let package_url = self.get_package_url(name);
let _guard = self.progress_bar.update(package_url.as_str());
- let response = match reqwest::get(package_url).await {
+ let response = match self.http_client.get(package_url).send().await {
Ok(response) => response,
Err(err) => {
// attempt to use the local cache