Maximum redirection option added. Performance improvement on exports. Duplicate requests only checked on GET requests.

This commit is contained in:
Musab Gültekin
2019-07-01 15:44:28 +03:00
parent 80f3500a69
commit c0dd0393e6
6 changed files with 71 additions and 16 deletions

View File

@ -207,3 +207,13 @@ func ConvertMapToHeader(m map[string]interface{}) http.Header {
}
return header
}
// NewRedirectionHandler returns maximum allowed redirection function with provided maxRedirect
func NewRedirectionHandler(maxRedirect int) func(req *http.Request, via []*http.Request) error {
return func(req *http.Request, via []*http.Request) error {
if len(via) >= maxRedirect {
return errors.Errorf("stopped after %d redirects", maxRedirect)
}
return nil
}
}