mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-24 18:59:34 +08:00
reusing http connections
This commit is contained in:
parent
054374c765
commit
c3ce024fc1
@ -21,6 +21,16 @@ type UploadResult struct {
|
||||
Error string
|
||||
}
|
||||
|
||||
var (
|
||||
client *http.Client
|
||||
)
|
||||
|
||||
func init() {
|
||||
client = &http.Client{Transport: &http.Transport{
|
||||
MaxIdleConnsPerHost: 1024,
|
||||
}}
|
||||
}
|
||||
|
||||
var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"")
|
||||
|
||||
func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool, mtype string) (*UploadResult, error) {
|
||||
@ -57,7 +67,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
||||
glog.V(0).Infoln("error closing body", err)
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.Post(uploadUrl, content_type, body_buf)
|
||||
resp, err := client.Post(uploadUrl, content_type, body_buf)
|
||||
if err != nil {
|
||||
glog.V(0).Infoln("failing to upload to", uploadUrl, err.Error())
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user