Explorar el Código

client: don't use nested actions

Brian Waldon hace 11 años
padre
commit
9fe78c8bc4
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      client/client.go

+ 3 - 2
client/client.go

@@ -299,13 +299,14 @@ type redirectFollowingHTTPClient struct {
 }
 
 func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
+	next := act
 	for i := 0; i < 100; i++ {
 		if i > 0 {
 			if err := r.checkRedirect(i); err != nil {
 				return nil, nil, err
 			}
 		}
-		resp, body, err := r.client.Do(ctx, act)
+		resp, body, err := r.client.Do(ctx, next)
 		if err != nil {
 			return nil, nil, err
 		}
@@ -318,7 +319,7 @@ func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*
 			if err != nil {
 				return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr)
 			}
-			act = &redirectedHTTPAction{
+			next = &redirectedHTTPAction{
 				action:   act,
 				location: *loc,
 			}