mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Add timeouts to HTTP client
This commit is contained in:
parent
2482a1a9ce
commit
5df50e2fc9
1 changed files with 8 additions and 2 deletions
|
@ -9,7 +9,7 @@ pub use isahc::{
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
use smol::future::FutureExt;
|
use smol::future::FutureExt;
|
||||||
use std::sync::Arc;
|
use std::{sync::Arc, time::Duration};
|
||||||
pub use url::Url;
|
pub use url::Url;
|
||||||
|
|
||||||
pub type Request = isahc::Request<AsyncBody>;
|
pub type Request = isahc::Request<AsyncBody>;
|
||||||
|
@ -41,7 +41,13 @@ pub trait HttpClient: Send + Sync {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn client() -> Arc<dyn HttpClient> {
|
pub fn client() -> Arc<dyn HttpClient> {
|
||||||
Arc::new(isahc::HttpClient::builder().build().unwrap())
|
Arc::new(
|
||||||
|
isahc::HttpClient::builder()
|
||||||
|
.connect_timeout(Duration::from_secs(5))
|
||||||
|
.low_speed_timeout(100, Duration::from_secs(5))
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HttpClient for isahc::HttpClient {
|
impl HttpClient for isahc::HttpClient {
|
||||||
|
|
Loading…
Reference in a new issue