From 6866a55f206896dc2b42b841d67fa9eb0dbb1244 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 9 Mar 2024 18:42:53 -0800 Subject: [PATCH] Add `Accept-Encoding: identity` to remaining stream paths (#2321) ## Summary Like #2319, there are a few other places where we attempt to stream a file. --- crates/uv-client/src/registry_client.rs | 7 +++++++ .../uv-distribution/src/distribution_database.rs | 7 +++++++ crates/uv-distribution/src/source/mod.rs | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index cdb3cff04..d4c403c2c 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -549,6 +549,13 @@ impl RegistryClient { .client .uncached() .get(url.clone()) + .header( + // `reqwest` defaults to accepting compressed responses. + // Specify identity encoding to get consistent .whl downloading + // behavior from servers. ref: https://github.com/pypa/pip/pull/1688 + "accept-encoding", + reqwest::header::HeaderValue::from_static("identity"), + ) .build() .map_err(ErrorKind::from)?; diff --git a/crates/uv-distribution/src/distribution_database.rs b/crates/uv-distribution/src/distribution_database.rs index 5200fa337..6e2f2274d 100644 --- a/crates/uv-distribution/src/distribution_database.rs +++ b/crates/uv-distribution/src/distribution_database.rs @@ -259,6 +259,13 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context> .cached_client() .uncached() .get(wheel.url.raw().clone()) + .header( + // `reqwest` defaults to accepting compressed responses. + // Specify identity encoding to get consistent .whl downloading + // behavior from servers. ref: https://github.com/pypa/pip/pull/1688 + "accept-encoding", + reqwest::header::HeaderValue::from_static("identity"), + ) .build()?; let cache_control = match self.client.connectivity() { Connectivity::Online => CacheControl::from( diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index 42f65ed3c..3ec954223 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -307,6 +307,13 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> { .cached_client() .uncached() .get(url.clone()) + .header( + // `reqwest` defaults to accepting compressed responses. + // Specify identity encoding to get consistent .whl downloading + // behavior from servers. ref: https://github.com/pypa/pip/pull/1688 + "accept-encoding", + reqwest::header::HeaderValue::from_static("identity"), + ) .build()?; let manifest = self .client @@ -410,6 +417,13 @@ impl<'a, T: BuildContext> SourceDistCachedBuilder<'a, T> { .cached_client() .uncached() .get(url.clone()) + .header( + // `reqwest` defaults to accepting compressed responses. + // Specify identity encoding to get consistent .whl downloading + // behavior from servers. ref: https://github.com/pypa/pip/pull/1688 + "accept-encoding", + reqwest::header::HeaderValue::from_static("identity"), + ) .build()?; let manifest = self .client