mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Set http timeout to 5s
This commit is contained in:
parent
0a3e83a36a
commit
39c7455881
|
@ -13,6 +13,7 @@ import (
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/security"
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
|
@ -30,9 +31,10 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
client = &http.Client{Transport: &http.Transport{
|
client = &http.Client{
|
||||||
MaxIdleConnsPerHost: 1024,
|
Transport: &http.Transport{MaxIdleConnsPerHost: 1024},
|
||||||
}}
|
Timeout: 5 * time.Second,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"")
|
var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"")
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/security"
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
)
|
)
|
||||||
|
@ -24,7 +25,10 @@ func init() {
|
||||||
Transport = &http.Transport{
|
Transport = &http.Transport{
|
||||||
MaxIdleConnsPerHost: 1024,
|
MaxIdleConnsPerHost: 1024,
|
||||||
}
|
}
|
||||||
client = &http.Client{Transport: Transport}
|
client = &http.Client{
|
||||||
|
Transport: Transport,
|
||||||
|
Timeout: 5 * time.Second,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func PostBytes(url string, body []byte) ([]byte, error) {
|
func PostBytes(url string, body []byte) ([]byte, error) {
|
||||||
|
@ -63,6 +67,8 @@ func Post(url string, values url.Values) ([]byte, error) {
|
||||||
return b, nil
|
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) {
|
func Get(url string) ([]byte, error) {
|
||||||
r, err := client.Get(url)
|
r, err := client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue