From d592624e59914a2c9f956fce0dbcff650181caf6 Mon Sep 17 00:00:00 2001 From: chenwanli Date: Thu, 10 Jan 2019 19:42:31 +0800 Subject: [PATCH] Set http timeout to 5s --- weed/operation/upload_content.go | 7 ++++--- weed/util/http_util.go | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index 030bf5889..b4dd0e149 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -30,9 +30,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 77a7a5fa3..fb927be02 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -24,7 +24,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 +66,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 {