1
0
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:
Nick Craig-Wood
2019-05-07 13:53:16 +01:00
parent b9e16b36e5
commit 8beab1aaf2
10 changed files with 7 additions and 58 deletions

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -1,5 +1,3 @@
// +build go1.8
package rest
import (