From 0b301b0b4786c9ae1fd82e84badf1487f8ce08a4 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 23 Aug 2020 21:32:29 -0700 Subject: [PATCH] consume all response body in order to release requests --- weed/operation/upload_content.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index f59c7e1a9..c036bce3b 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -226,6 +226,10 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error return nil, fmt.Errorf("failing to upload to %v: %v", uploadUrl, post_err) } defer resp.Body.Close() + resp_body, ra_err := ioutil.ReadAll(resp.Body) + if ra_err != nil { + return nil, ra_err + } var ret UploadResult etag := getEtag(resp) @@ -233,10 +237,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error ret.ETag = etag return &ret, nil } - resp_body, ra_err := ioutil.ReadAll(resp.Body) - if ra_err != nil { - return nil, ra_err - } + unmarshal_err := json.Unmarshal(resp_body, &ret) if unmarshal_err != nil { glog.V(0).Infoln("failing to read upload response", uploadUrl, string(resp_body))