Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fetching work when package is in Amazon S3 #2843

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/uv-client/src/registry_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::str::FromStr;
use async_http_range_reader::AsyncHttpRangeReader;
use futures::{FutureExt, TryStreamExt};
use http::HeaderMap;
use reqwest::{Client, Response, StatusCode};
use reqwest::{Client, Response, ResponseBuilderExt, StatusCode};
use serde::{Deserialize, Serialize};
use tokio::io::AsyncReadExt;
use tokio_util::compat::{FuturesAsyncReadCompatExt, TokioAsyncReadCompatExt};
Expand Down Expand Up @@ -520,7 +520,7 @@ impl RegistryClient {
async {
let mut reader = AsyncHttpRangeReader::from_head_response(
self.uncached_client().client(),
response,
response_with_original_url(response, url.clone()),
headers,
)
.await
Expand Down Expand Up @@ -612,6 +612,18 @@ impl RegistryClient {
}
}

fn response_with_original_url(response: Response, original_url: Url) -> Response {
let mut r = http::Response::builder()
.status(response.status())
.url(original_url)
.version(response.version());
for (name, value) in response.headers() {
r = r.header(name, value);
}
let r = r.body("").unwrap();
Response::from(r)
}

/// Read a wheel's `METADATA` file from a zip file.
async fn read_metadata_async_seek(
filename: &WheelFilename,
Expand Down
Loading