Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Set http timeout to 5s

chenwanli39c745588111
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go
index 030bf58895..8cf31e3828 100644
--- a/weed/operation/upload_content.go
+++ b/weed/operation/upload_content.go
@@ -13,6 +13,7 @@ import (
"net/textproto"
"path/filepath"
"strings"
+ "time"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/security"
@@ -30,9 +31,10 @@ var (
)
func init() {
- client = &http.Client{Transport: &http.Transport{
- MaxIdleConnsPerHost: 1024,
- }}
+ client = &http.Client{
+ Transport: &http.Transport{MaxIdleConnsPerHost: 1024},
+ Timeout: 5 * time.Second,
+ }
}
var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"")
diff --git a/weed/util/http_util.go b/weed/util/http_util.go
index 77a7a5fa3e..21e0a678d6 100644
--- a/weed/util/http_util.go
+++ b/weed/util/http_util.go
@@ -11,6 +11,7 @@ import (
"net/http"
"net/url"
"strings"
+ "time"
"github.com/chrislusf/seaweedfs/weed/security"
)
@@ -24,7 +25,10 @@ func init() {
Transport = &http.Transport{
MaxIdleConnsPerHost: 1024,
}
- client = &http.Client{Transport: Transport}
+ client = &http.Client{
+ Transport: Transport,
+ Timeout: 5 * time.Second,
+ }
}
func PostBytes(url string, body []byte) ([]byte, error) {
@@ -63,6 +67,8 @@ func Post(url string, values url.Values) ([]byte, error) {
return b, nil
}
+// github.com/chrislusf/seaweedfs/unmaintained/repeated_vacuum/repeated_vacuum.go
+// may need increasing http.Client.Timeout
func Get(url string) ([]byte, error) {
r, err := client.Get(url)
if err != nil {