Merge pull request #755 from wnstar/master

add SetRedirectLimit function to do HTTP client. #714
This commit is contained in:
John Guo
2020-06-22 21:21:05 +08:00
committed by GitHub

View File

@ -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
}