mirror of
https://gitee.com/johng/gf
synced 2026-06-27 17:57:21 +08:00
Merge pull request #755 from wnstar/master
add SetRedirectLimit function to do HTTP client. #714
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