forked from TrueCloudLab/rclone
vendor: update github.com/ncw/swift to help with #3041
This commit is contained in:
parent
2065e73d0b
commit
b0380aad95
5 changed files with 17 additions and 12 deletions
4
vendor/github.com/ncw/swift/compatibility_1_6.go
generated
vendored
4
vendor/github.com/ncw/swift/compatibility_1_6.go
generated
vendored
|
@ -14,7 +14,9 @@ func SetExpectContinueTimeout(tr *http.Transport, t time.Duration) {
|
|||
}
|
||||
|
||||
func AddExpectAndTransferEncoding(req *http.Request, hasContentLength bool) {
|
||||
req.Header.Add("Expect", "100-continue")
|
||||
if req.Body != nil {
|
||||
req.Header.Add("Expect", "100-continue")
|
||||
}
|
||||
if !hasContentLength {
|
||||
req.TransferEncoding = []string{"chunked"}
|
||||
}
|
||||
|
|
19
vendor/github.com/ncw/swift/swift.go
generated
vendored
19
vendor/github.com/ncw/swift/swift.go
generated
vendored
|
@ -308,6 +308,7 @@ var (
|
|||
Forbidden = newError(403, "Operation forbidden")
|
||||
TooLargeObject = newError(413, "Too Large Object")
|
||||
RateLimit = newError(498, "Rate Limit")
|
||||
TooManyRequests = newError(429, "TooManyRequests")
|
||||
|
||||
// Mappings for authentication errors
|
||||
authErrorMap = errorMap{
|
||||
|
@ -333,6 +334,7 @@ var (
|
|||
404: ObjectNotFound,
|
||||
413: TooLargeObject,
|
||||
422: ObjectCorrupted,
|
||||
429: TooManyRequests,
|
||||
498: RateLimit,
|
||||
}
|
||||
)
|
||||
|
@ -734,11 +736,11 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
|
|||
for k, v := range p.Headers {
|
||||
// Set ContentLength in req if the user passed it in in the headers
|
||||
if k == "Content-Length" {
|
||||
contentLength, err := strconv.ParseInt(v, 10, 64)
|
||||
req.ContentLength, err = strconv.ParseInt(v, 10, 64)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("Invalid %q header %q: %v", k, v, err)
|
||||
err = fmt.Errorf("Invalid %q header %q: %v", k, v, err)
|
||||
return
|
||||
}
|
||||
req.ContentLength = contentLength
|
||||
} else {
|
||||
req.Header.Add(k, v)
|
||||
}
|
||||
|
@ -756,7 +758,7 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
|
|||
retries--
|
||||
continue
|
||||
}
|
||||
return nil, nil, err
|
||||
return
|
||||
}
|
||||
// Check to see if token has expired
|
||||
if resp.StatusCode == 401 && retries > 0 {
|
||||
|
@ -768,15 +770,14 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
|
|||
}
|
||||
}
|
||||
|
||||
if err = c.parseHeaders(resp, p.ErrorMap); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
headers = readHeaders(resp)
|
||||
if err = c.parseHeaders(resp, p.ErrorMap); err != nil {
|
||||
return
|
||||
}
|
||||
if p.NoResponse {
|
||||
var err error
|
||||
drainAndClose(resp.Body, &err)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// Cancel the request on timeout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue