Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rest: use readers.NoCloser to stop body being closed

Nick Craig-Wooda992a910ef9b
diff --git a/lib/rest/rest.go b/lib/rest/rest.go
index dd0b3004d..0796c3e43 100644
--- a/lib/rest/rest.go
+++ b/lib/rest/rest.go
@@ -16,6 +16,7 @@ import (
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
+ "github.com/rclone/rclone/lib/readers"
)
// Client contains the info to sustain the API
@@ -198,7 +199,7 @@ func (api *Client) Call(opts *Opts) (resp *http.Response, err error) {
if opts.Parameters != nil && len(opts.Parameters) > 0 {
url += "?" + opts.Parameters.Encode()
}
- body := opts.Body
+ body := readers.NoCloser(opts.Body)
// If length is set and zero then nil out the body to stop use
// use of chunked encoding and insert a "Content-Length: 0"
// header.