mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
fix: vmagent not follow 301/302 redirect bug (#445)
Co-authored-by: xiaobeibei <xiaobeibei@bigo.sg>
This commit is contained in:
parent
50af16baf2
commit
7d045bf2ca
1 changed files with 9 additions and 0 deletions
|
@ -124,6 +124,15 @@ var (
|
||||||
func doRequestWithPossibleRetry(hc *fasthttp.HostClient, req *fasthttp.Request, resp *fasthttp.Response) error {
|
func doRequestWithPossibleRetry(hc *fasthttp.HostClient, req *fasthttp.Request, resp *fasthttp.Response) error {
|
||||||
// There is no need in calling DoTimeout, since the timeout must be already set in hc.ReadTimeout.
|
// There is no need in calling DoTimeout, since the timeout must be already set in hc.ReadTimeout.
|
||||||
err := hc.Do(req, resp)
|
err := hc.Do(req, resp)
|
||||||
|
if err == nil && (resp.Header.StatusCode() == 301 || resp.Header.StatusCode() == 302) {
|
||||||
|
l := string(resp.Header.Peek("Location"))
|
||||||
|
if l != "" {
|
||||||
|
req.URI().Update(l)
|
||||||
|
// only redirect once
|
||||||
|
err = hc.Do(req, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue