From 4542f86ad79abc04a00772a12d61d3e008f8ac25 Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Thu, 26 Dec 2024 14:19:39 +0400 Subject: [PATCH] allow 2 redirects for http client --- transport/httptransport/http_transport.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport/httptransport/http_transport.go b/transport/httptransport/http_transport.go index 0716aca1e..9d8db46e6 100644 --- a/transport/httptransport/http_transport.go +++ b/transport/httptransport/http_transport.go @@ -210,8 +210,12 @@ func (h *httpTransport) Execute(ctx context.Context, transportInfo []byte, dealI } else { // do not follow http redirects for security reasons t.client = &http.Client{ + // Custom CheckRedirect function to limit redirects CheckRedirect: func(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse + if len(via) >= 2 { // Limit to 2 redirects + return fmt.Errorf("too many redirects: %d", len(via)) + } + return nil }, }