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

build: more pre go1.8 workarounds removed

Nick Craig-Wood8beab1aaf2e1
diff --git a/backend/amazonclouddrive/amazonclouddrive.go b/backend/amazonclouddrive/amazonclouddrive.go
index a61227e23..9eafc6f08 100644
--- a/backend/amazonclouddrive/amazonclouddrive.go
+++ b/backend/amazonclouddrive/amazonclouddrive.go
@@ -32,7 +32,6 @@ import (
"github.com/ncw/rclone/lib/dircache"
"github.com/ncw/rclone/lib/oauthutil"
"github.com/ncw/rclone/lib/pacer"
- "github.com/ncw/rclone/lib/rest"
"github.com/pkg/errors"
"golang.org/x/oauth2"
)
@@ -1093,7 +1092,7 @@ func (o *Object) Open(options ...fs.OpenOption) (in io.ReadCloser, err error) {
if !bigObject {
in, resp, err = file.OpenHeaders(headers)
} else {
- in, resp, err = file.OpenTempURLHeaders(rest.ClientWithHeaderReset(o.fs.noAuthClient, headers), headers)
+ in, resp, err = file.OpenTempURLHeaders(o.fs.noAuthClient, headers)
}
return o.fs.shouldRetry(resp, err)
})
diff --git a/cmd/mount/dir.go b/cmd/mount/dir.go
index e95281119..1075cd0c5 100644
--- a/cmd/mount/dir.go
+++ b/cmd/mount/dir.go
@@ -3,6 +3,7 @@
package mount
import (
+ "context"
"os"
"time"
@@ -12,7 +13,6 @@ import (
"github.com/ncw/rclone/fs/log"
"github.com/ncw/rclone/vfs"
"github.com/pkg/errors"
- "golang.org/x/net/context" // switch to "context" when we stop supporting go1.8
)
// Dir represents a directory entry
diff --git a/cmd/mount/file.go b/cmd/mount/file.go
index d03d52d0b..133f51175 100644
--- a/cmd/mount/file.go
+++ b/cmd/mount/file.go
@@ -3,6 +3,7 @@
package mount
import (
+ "context"
"io"
"time"
@@ -11,7 +12,6 @@ import (
"github.com/ncw/rclone/cmd/mountlib"
"github.com/ncw/rclone/fs/log"
"github.com/ncw/rclone/vfs"
- "golang.org/x/net/context" // switch to "context" when we stop supporting go1.8
)
// File represents a file
diff --git a/cmd/mount/fs.go b/cmd/mount/fs.go
index 64a8d9d48..b0237605d 100644
--- a/cmd/mount/fs.go
+++ b/cmd/mount/fs.go
@@ -5,6 +5,7 @@
package mount
import (
+ "context"
"syscall"
"bazil.org/fuse"
@@ -15,7 +16,6 @@ import (
"github.com/ncw/rclone/vfs"
"github.com/ncw/rclone/vfs/vfsflags"
"github.com/pkg/errors"
- "golang.org/x/net/context" // switch to "context" when we stop supporting go1.8
)
// FS represents the top level filing system
diff --git a/cmd/mount/handle.go b/cmd/mount/handle.go
index 5d32a7d7b..2c049abc9 100644
--- a/cmd/mount/handle.go
+++ b/cmd/mount/handle.go
@@ -3,13 +3,13 @@
package mount
import (
+ "context"
"io"
"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
"github.com/ncw/rclone/fs/log"
"github.com/ncw/rclone/vfs"
- "golang.org/x/net/context" // switch to "context" when we stop supporting go1.8
)
// FileHandle is an open for read file handle on a File
diff --git a/cmd/serve/webdav/webdav.go b/cmd/serve/webdav/webdav.go
index 88fa90db9..b039f73f5 100644
--- a/cmd/serve/webdav/webdav.go
+++ b/cmd/serve/webdav/webdav.go
@@ -3,6 +3,7 @@
package webdav
import (
+ "context"
"net/http"
"os"
@@ -15,7 +16,6 @@ import (
"github.com/ncw/rclone/vfs"
"github.com/ncw/rclone/vfs/vfsflags"
"github.com/spf13/cobra"
- "golang.org/x/net/context" // switch to "context" when we stop supporting go1.8
"golang.org/x/net/webdav"
)
diff --git a/lib/rest/rest.go b/lib/rest/rest.go
index e26336560..6c21f6088 100644
--- a/lib/rest/rest.go
+++ b/lib/rest/rest.go
@@ -253,7 +253,7 @@ func (api *Client) Call(opts *Opts) (resp *http.Response, err error) {
if opts.NoRedirect {
c = ClientWithNoRedirects(api.c)
} else {
- c = ClientWithHeaderReset(api.c, headers)
+ c = api.c
}
if api.signer != nil {
err = api.signer(req)
diff --git a/lib/rest/rest_header_reset.go b/lib/rest/rest_header_reset.go
deleted file mode 100644
index 9557c1d2a..000000000
--- a/lib/rest/rest_header_reset.go
+++ /dev/null
@@ -1,15 +0,0 @@
-//+build go1.8
-
-package rest
-
-import (
- "net/http"
-)
-
-// ClientWithHeaderReset makes a new http client which resets the
-// headers passed in on redirect
-//
-// This is now unnecessary with go1.8 so becomes a no-op
-func ClientWithHeaderReset(c *http.Client, headers map[string]string) *http.Client {
- return c
-}
diff --git a/lib/rest/rest_header_reset_go17.go b/lib/rest/rest_header_reset_go17.go
deleted file mode 100644
index 7b3109b57..000000000
--- a/lib/rest/rest_header_reset_go17.go
+++ /dev/null
@@ -1,33 +0,0 @@
-//+build !go1.8
-
-package rest
-
-import (
- "net/http"
-
- "github.com/pkg/errors"
-)
-
-// ClientWithHeaderReset makes a new http client which resets the
-// headers passed in on redirect
-//
-// This is only needed for go < go1.8
-func ClientWithHeaderReset(c *http.Client, headers map[string]string) *http.Client {
- if len(headers) == 0 {
- return c
- }
- clientCopy := *c
- clientCopy.CheckRedirect = func(req *http.Request, via []*http.Request) error {
- if len(via) >= 10 {
- return errors.New("stopped after 10 redirects")
- }
- // Reset the headers in the new request
- for k, v := range headers {
- if v != "" {
- req.Header.Set(k, v)
- }
- }
- return nil
- }
- return &clientCopy
-}
diff --git a/lib/rest/url_test.go b/lib/rest/url_test.go
index 7a7e51bdf..3f481dfd9 100644
--- a/lib/rest/url_test.go
+++ b/lib/rest/url_test.go
@@ -1,5 +1,3 @@
-// +build go1.8
-
package rest
import (