Skip to content

Commit

Permalink
Reuse Client when pulling packages over the network (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-nick authored Aug 31, 2021
1 parent 0bd35e6 commit dd016d8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/package_source/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Registry {
index_url: Url,
auth_token: OnceCell<Option<Arc<str>>>,
index: OnceCell<PackageIndex>,
client: Client,
}

impl Registry {
Expand All @@ -29,6 +30,7 @@ impl Registry {
index_url,
auth_token: OnceCell::new(),
index: OnceCell::new(),
client: Client::new(),
})
}

Expand Down Expand Up @@ -84,9 +86,7 @@ impl PackageSource for Registry {

let url = self.api_url()?.join(&path)?;

let client = Client::new();

let mut request = client.get(url);
let mut request = self.client.get(url);

if let Some(token) = self.auth_token()? {
request = request.header(AUTHORIZATION, format!("Bearer {}", token));
Expand Down

0 comments on commit dd016d8

Please sign in to comment.