This commit is contained in:
parent
e15755fef0
commit
f97f1d532e
@ -12,7 +12,7 @@ import (
|
|||||||
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
|
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
|
||||||
var r *http.Request
|
var r *http.Request
|
||||||
var retryBuf io.Reader
|
var retryBuf io.Reader
|
||||||
|
canRetry := true
|
||||||
if body != nil {
|
if body != nil {
|
||||||
// If the authorization fails, we will need to restart reading
|
// If the authorization fails, we will need to restart reading
|
||||||
// from the passed body stream.
|
// from the passed body stream.
|
||||||
@ -25,6 +25,8 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
retryBuf = body
|
retryBuf = body
|
||||||
|
} else if method == http.MethodPut {
|
||||||
|
canRetry = false
|
||||||
} else {
|
} else {
|
||||||
buff := &bytes.Buffer{}
|
buff := &bytes.Buffer{}
|
||||||
retryBuf = buff
|
retryBuf = buff
|
||||||
@ -83,7 +85,9 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
|||||||
|
|
||||||
// retryBuf will be nil if body was nil initially so no check
|
// retryBuf will be nil if body was nil initially so no check
|
||||||
// for body == nil is required here.
|
// for body == nil is required here.
|
||||||
return c.req(method, path, retryBuf, intercept)
|
if canRetry {
|
||||||
|
return c.req(method, path, retryBuf, intercept)
|
||||||
|
}
|
||||||
} else if rs.StatusCode == 401 {
|
} else if rs.StatusCode == 401 {
|
||||||
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
||||||
}
|
}
|
||||||
@ -193,7 +197,7 @@ func (c *Client) copymove(method string, oldpath string, newpath string, overwri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) put(path string, stream io.Reader, callback func(r *http.Request)) (status int, err error) {
|
func (c *Client) put(path string, stream io.Reader, callback func(r *http.Request)) (status int, err error) {
|
||||||
rs, err := c.req("PUT", path, stream, callback)
|
rs, err := c.req(http.MethodPut, path, stream, callback)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user