Close the response body when 301 is returned in the WebDAV backend

This commit is contained in:
Gilbert Chen
2020-09-14 11:36:22 -04:00
parent 40243fb043
commit 97bae5f1a3

View File

@@ -174,12 +174,13 @@ func (storage *WebDAVStorage) sendRequest(method string, uri string, depth int,
return response.Body, response.Header, nil
}
io.Copy(ioutil.Discard, response.Body)
response.Body.Close()
if response.StatusCode == 301 {
return nil, nil, errWebDAVMovedPermanently
}
io.Copy(ioutil.Discard, response.Body)
response.Body.Close()
if response.StatusCode == 404 {
// Retry if it is UPLOAD, otherwise return immediately
if method != "PUT" {