mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape/discoveryutils: re-use checkRedirect function for both client and blockingClient
Also document follow_redirects option at https://docs.victoriametrics.com/sd_configs.html#http-api-client-options
This is a follow-up for b3d0ff463a
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4282
This commit is contained in:
parent
45e345806c
commit
792860db10
2 changed files with 7 additions and 4 deletions
|
@ -1607,4 +1607,8 @@ and in the majority of [supported service discovery configs](#supported-service-
|
|||
# proxy_headers:
|
||||
# - "HeaderName1: HeaderValue"
|
||||
# - "HeaderNameN: HeaderValueN"
|
||||
|
||||
# follow_redirects can be used for disallowing HTTP redirects.
|
||||
# By default HTTP redirects are followed.
|
||||
# follow_redirects: false
|
||||
```
|
||||
|
|
|
@ -143,12 +143,11 @@ func NewClient(apiServer string, ac *promauth.Config, proxyURL *proxy.URL, proxy
|
|||
}
|
||||
}
|
||||
if httpCfg.FollowRedirects != nil && !*httpCfg.FollowRedirects {
|
||||
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
blockingClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||
checkRedirect := func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
client.CheckRedirect = checkRedirect
|
||||
blockingClient.CheckRedirect = checkRedirect
|
||||
}
|
||||
setHTTPProxyHeaders := func(req *http.Request) {}
|
||||
if proxyAC != nil {
|
||||
|
|
Loading…
Reference in a new issue