aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-03-12 14:07:01 -0700
committerChris Lu <chris.lu@gmail.com>2014-03-12 14:07:01 -0700
commitc3ce024fc1a1e7841ac57e77313d967df45a5ee1 (patch)
tree550a028603bf9014b755ce4a7315ef4687010756 /go
parent054374c765bc0dea51c524bf8cb137d1ea356254 (diff)
downloadseaweedfs-c3ce024fc1a1e7841ac57e77313d967df45a5ee1.tar.xz
seaweedfs-c3ce024fc1a1e7841ac57e77313d967df45a5ee1.zip
reusing http connections
Diffstat (limited to 'go')
-rw-r--r--go/operation/upload_content.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go
index 17fe9e1c3..7d88b3721 100644
--- a/go/operation/upload_content.go
+++ b/go/operation/upload_content.go
@@ -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