mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
build: more pre go1.8 workarounds removed
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
// +build go1.8
|
||||
|
||||
package rest
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user