Skip to content

Commit

Permalink
allow 2 redirects for http client
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Dec 26, 2024
1 parent 86de509 commit 4542f86
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion transport/httptransport/http_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}

Expand Down

0 comments on commit 4542f86

Please sign in to comment.