From 97bae5f1a3bc5664e9685818a06f01e593867b1c Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Mon, 14 Sep 2020 11:36:22 -0400 Subject: [PATCH] Close the response body when 301 is returned in the WebDAV backend --- src/duplicacy_webdavstorage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/duplicacy_webdavstorage.go b/src/duplicacy_webdavstorage.go index e153680..00bc615 100644 --- a/src/duplicacy_webdavstorage.go +++ b/src/duplicacy_webdavstorage.go @@ -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" {