mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
client: don't use nested actions
This commit is contained in:
parent
25cf916a80
commit
9fe78c8bc4
@ -299,13 +299,14 @@ type redirectFollowingHTTPClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
|
func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
|
||||||
|
next := act
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
if err := r.checkRedirect(i); err != nil {
|
if err := r.checkRedirect(i); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp, body, err := r.client.Do(ctx, act)
|
resp, body, err := r.client.Do(ctx, next)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -318,7 +319,7 @@ func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr)
|
return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr)
|
||||||
}
|
}
|
||||||
act = &redirectedHTTPAction{
|
next = &redirectedHTTPAction{
|
||||||
action: act,
|
action: act,
|
||||||
location: *loc,
|
location: *loc,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user