This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 6f4116579 fix: Set default timeouts for HttpClient (#2895)
6f4116579 is described below
commit 6f411657991be2038a035225719fbb0a1a1b9fad
Author: Kousuke Saruta <[email protected]>
AuthorDate: Tue Aug 22 12:04:29 2023 +0900
fix: Set default timeouts for HttpClient (#2895)
* Add default timeouts for HttpClient.
* Fix style.
* Remove request timeout.
---
core/src/raw/http_util/client.rs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/core/src/raw/http_util/client.rs b/core/src/raw/http_util/client.rs
index 9578af9ce..d0926d1cd 100644
--- a/core/src/raw/http_util/client.rs
+++ b/core/src/raw/http_util/client.rs
@@ -19,6 +19,7 @@ use std::fmt::Debug;
use std::fmt::Formatter;
use std::mem;
use std::str::FromStr;
+use std::time::Duration;
use futures::TryStreamExt;
use http::Request;
@@ -32,6 +33,8 @@ use crate::Error;
use crate::ErrorKind;
use crate::Result;
+const DEFAULT_CONNECT_TIMEOUT: Duration = Duration::from_secs(60);
+
/// HttpClient that used across opendal.
#[derive(Clone)]
pub struct HttpClient {
@@ -59,6 +62,8 @@ impl HttpClient {
builder = builder.no_brotli();
// Make sure we don't enable auto deflate decompress.
builder = builder.no_deflate();
+ // Make sure we don't wait a connection establishment forever.
+ builder = builder.connect_timeout(DEFAULT_CONNECT_TIMEOUT);
#[cfg(feature = "trust-dns")]
let builder = builder.trust_dns(true);