Enforce HTTP timeouts on a per-read (rather than per-request) basis (#3144)

## Summary

This leverages the new `read_timeout` property, which ensures that (like
pip) our timeout is not applied to the _entire_ request, but rather, to
each individual read operation.

Closes: #1921.

See: #1912.
This commit is contained in:
Charlie Marsh 2024-04-19 16:49:53 -04:00 committed by GitHub
parent 31765c05bd
commit 9f2bc19eaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

6
Cargo.lock generated
View File

@ -2732,7 +2732,7 @@ dependencies = [
"indoc", "indoc",
"libc", "libc",
"memoffset 0.9.1", "memoffset 0.9.1",
"parking_lot 0.12.1", "parking_lot 0.11.2",
"portable-atomic", "portable-atomic",
"pyo3-build-config", "pyo3-build-config",
"pyo3-ffi", "pyo3-ffi",
@ -3025,9 +3025,9 @@ dependencies = [
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.12.3" version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10"
dependencies = [ dependencies = [
"async-compression", "async-compression",
"base64 0.22.0", "base64 0.22.0",

View File

@ -125,7 +125,7 @@ impl<'a> BaseClientBuilder<'a> {
}) })
}) })
.unwrap_or(default_timeout); .unwrap_or(default_timeout);
debug!("Using registry request timeout of {}s", timeout); debug!("Using registry request timeout of {timeout}s");
// Initialize the base client. // Initialize the base client.
let client = self.client.clone().unwrap_or_else(|| { let client = self.client.clone().unwrap_or_else(|| {
@ -145,7 +145,7 @@ impl<'a> BaseClientBuilder<'a> {
let client_core = ClientBuilder::new() let client_core = ClientBuilder::new()
.user_agent(user_agent_string) .user_agent(user_agent_string)
.pool_max_idle_per_host(20) .pool_max_idle_per_host(20)
.timeout(std::time::Duration::from_secs(timeout)) .read_timeout(std::time::Duration::from_secs(timeout))
.tls_built_in_root_certs(false); .tls_built_in_root_certs(false);
// Configure TLS. // Configure TLS.