Proxy: one copy of the rules, none of it per request
Co-Authored-By: WorkBuddy AI (DeepSeek-V4.1-Flash) <noreply@workbuddy.cn>
This commit is contained in:
@@ -19,18 +19,24 @@ const MAX: u64 = 1 << 30;
|
||||
|
||||
/// The HTTP agent the sources share, reaching `url` through the player's proxy when one is set
|
||||
/// (`proxy`). Modrinth asks for a user agent that names the project.
|
||||
///
|
||||
/// It is kept between downloads: a fresh agent starts a new connection pool, so one per file would
|
||||
/// be a handshake per file, and a modpack brings hundreds.
|
||||
pub(super) fn agent(url: &str) -> ureq::Agent {
|
||||
crate::proxy::agent(
|
||||
ureq::AgentBuilder::new()
|
||||
let spec = crate::proxy::spec_for(url);
|
||||
horizon_port_pack::net::keep("browser", spec.as_deref(), |proxy| {
|
||||
let builder = ureq::AgentBuilder::new()
|
||||
.user_agent(&format!(
|
||||
"ludovic111/horizon horizon-launcher/{} (github.com/ludovic111/horizon)",
|
||||
crate::backend::VERSION
|
||||
))
|
||||
.timeout_connect(std::time::Duration::from_secs(15))
|
||||
.timeout_read(std::time::Duration::from_secs(60)),
|
||||
url,
|
||||
)
|
||||
.build()
|
||||
.timeout_read(std::time::Duration::from_secs(60));
|
||||
match proxy {
|
||||
Some(proxy) => builder.proxy(proxy).build(),
|
||||
None => builder.build(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Why a file can't be downloaded at all, before any byte is read.
|
||||
|
||||
Reference in New Issue
Block a user