mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-13 13:11:37 +01: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
eb47ad4b69
commit
6a3cee5c2c
@ -1607,4 +1607,8 @@ and in the majority of [supported service discovery configs](#supported-service-
|
|||||||
# proxy_headers:
|
# proxy_headers:
|
||||||
# - "HeaderName1: HeaderValue"
|
# - "HeaderName1: HeaderValue"
|
||||||
# - "HeaderNameN: HeaderValueN"
|
# - "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 {
|
if httpCfg.FollowRedirects != nil && !*httpCfg.FollowRedirects {
|
||||||
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
checkRedirect := func(req *http.Request, via []*http.Request) error {
|
||||||
return http.ErrUseLastResponse
|
|
||||||
}
|
|
||||||
blockingClient.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
|
||||||
return http.ErrUseLastResponse
|
return http.ErrUseLastResponse
|
||||||
}
|
}
|
||||||
|
client.CheckRedirect = checkRedirect
|
||||||
|
blockingClient.CheckRedirect = checkRedirect
|
||||||
}
|
}
|
||||||
setHTTPProxyHeaders := func(req *http.Request) {}
|
setHTTPProxyHeaders := func(req *http.Request) {}
|
||||||
if proxyAC != nil {
|
if proxyAC != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user