From 51bb919a28818e5c188e1e5fcc63a99c5c001778 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 26 Sep 2024 04:03:52 +0700 Subject: [PATCH] perf: use abbreviated json --- crates/registry/src/package.rs | 8 +++++++- crates/registry/src/package_version.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/registry/src/package.rs b/crates/registry/src/package.rs index 3bd4f087..024c8817 100644 --- a/crates/registry/src/package.rs +++ b/crates/registry/src/package.rs @@ -36,7 +36,13 @@ impl Package { let network_error = |error| NetworkError { error, url: url() }; http_client .run_with_permit(|client| { - client.get(url()).header("content-type", "application/json").send() + client + .get(url()) + .header( + "accept", + "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*", + ) + .send() }) .await .map_err(network_error)? diff --git a/crates/registry/src/package_version.rs b/crates/registry/src/package_version.rs index 009b75d8..dc5f36a3 100644 --- a/crates/registry/src/package_version.rs +++ b/crates/registry/src/package_version.rs @@ -35,7 +35,13 @@ impl PackageVersion { http_client .run_with_permit(|client| { - client.get(url()).header("content-type", "application/json").send() + client + .get(url()) + .header( + "accept", + "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*", + ) + .send() }) .await .map_err(network_error)?