mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
add SetRedirectLimit function to client
This commit is contained in:
@ -147,3 +147,14 @@ func (c *Client) SetRetry(retryCount int, retryInterval time.Duration) *Client {
|
||||
c.retryInterval = retryInterval
|
||||
return c
|
||||
}
|
||||
|
||||
// SetRedirectLimit limit the number of jumps
|
||||
func (c *Client) SetRedirectLimit(redirectLimit int) *Client {
|
||||
c.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= redirectLimit {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user