mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
close http response
This commit is contained in:
parent
0b301b0b47
commit
5f55a87101
|
@ -225,11 +225,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
|||
glog.V(1).Infof("failing to upload to %v: %v", uploadUrl, post_err)
|
||||
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
|
||||
}
|
||||
defer util.CloseResponse(resp)
|
||||
|
||||
var ret UploadResult
|
||||
etag := getEtag(resp)
|
||||
|
@ -238,6 +234,11 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
|||
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))
|
||||
|
|
|
@ -368,6 +368,7 @@ func ReadUrlAsReaderCloser(fileUrl string, rangeHeader string) (io.ReadCloser, e
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer CloseResponse(r)
|
||||
if r.StatusCode >= 400 {
|
||||
return nil, fmt.Errorf("%s: %s", fileUrl, r.Status)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue