mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix(rust): restore the 10s connect timeout and share media clients across proxy settings
Python OCR passes the call timeout per request, so its connect timeout is the call timeout and never the 5s handler default. 10s is what every Rust route uses on main. The media client never uses a proxy, so trust_proxy_env no longer splits its pool key
This commit is contained in:
parent
c635c35b3d
commit
0119f50015
2 changed files with 17 additions and 2 deletions
|
|
@ -51,6 +51,7 @@ impl HttpClientPool {
|
|||
let effective = match variant {
|
||||
ClientVariant::Media => HttpClientConfig {
|
||||
client_certificate: None,
|
||||
trust_proxy_env: false,
|
||||
..config.clone()
|
||||
},
|
||||
ClientVariant::Provider | ClientVariant::NoRedirect => config.clone(),
|
||||
|
|
@ -86,7 +87,6 @@ impl HttpClientPool {
|
|||
ClientVariant::NoRedirect => builder.redirect(reqwest::redirect::Policy::none()),
|
||||
ClientVariant::Media => builder
|
||||
.redirect(reqwest::redirect::Policy::none())
|
||||
.no_proxy()
|
||||
.dns_resolver2(Arc::clone(&self.media_resolver)),
|
||||
}
|
||||
}
|
||||
|
|
@ -206,6 +206,21 @@ mod tests {
|
|||
assert_eq!(connections.load(Ordering::SeqCst), 2);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn media_clients_are_shared_across_proxy_settings_they_never_use() {
|
||||
let (address, connections, _) = serve("HTTP/1.1 204 No Content").await;
|
||||
let pool = HttpClientPool::new(Arc::new(FixedResolver(address)));
|
||||
let url = format!("http://media.invalid:{}/doc", address.port());
|
||||
for trust_proxy_env in [true, false] {
|
||||
let config = HttpClientConfig {
|
||||
trust_proxy_env,
|
||||
..config("a")
|
||||
};
|
||||
get(&pool, &config, ClientVariant::Media, &url).await;
|
||||
}
|
||||
assert_eq!(connections.load(Ordering::SeqCst), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn media_variant_never_loads_the_client_certificate() {
|
||||
let pool = pool();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl Default for HttpSettings {
|
|||
user_agent: None,
|
||||
trust_proxy_env: false,
|
||||
ignore_proxy_env: false,
|
||||
connect_timeout: Duration::from_secs(5),
|
||||
connect_timeout: Duration::from_secs(10),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue