mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
lib/promscrape: properly send full url in GET
request via simple HTTP proxy
This is a follow-up for a0ae0f86666a75ec57b45eab2429da7ab4a7b250 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1179
This commit is contained in:
parent
5153410ced
commit
500e625e8c
2 changed files with 4 additions and 2 deletions
|
@ -184,7 +184,7 @@ func (c *client) ReadData(dst []byte) ([]byte, error) {
|
||||||
deadline := time.Now().Add(c.hc.ReadTimeout)
|
deadline := time.Now().Add(c.hc.ReadTimeout)
|
||||||
req := fasthttp.AcquireRequest()
|
req := fasthttp.AcquireRequest()
|
||||||
req.SetRequestURI(c.requestURI)
|
req.SetRequestURI(c.requestURI)
|
||||||
req.SetHost(c.host)
|
req.Header.SetHost(c.host)
|
||||||
// The following `Accept` header has been copied from Prometheus sources.
|
// The following `Accept` header has been copied from Prometheus sources.
|
||||||
// See https://github.com/prometheus/prometheus/blob/f9d21f10ecd2a343a381044f131ea4e46381ce09/scrape/scrape.go#L532 .
|
// See https://github.com/prometheus/prometheus/blob/f9d21f10ecd2a343a381044f131ea4e46381ce09/scrape/scrape.go#L532 .
|
||||||
// This is needed as a workaround for scraping stupid Java-based servers such as Spring Boot.
|
// This is needed as a workaround for scraping stupid Java-based servers such as Spring Boot.
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Client struct {
|
||||||
|
|
||||||
apiServer string
|
apiServer string
|
||||||
|
|
||||||
|
hostPort string
|
||||||
authHeader string
|
authHeader string
|
||||||
proxyAuthHeader string
|
proxyAuthHeader string
|
||||||
sendFullURL bool
|
sendFullURL bool
|
||||||
|
@ -127,6 +128,7 @@ func NewClient(apiServer string, ac *promauth.Config, proxyURL proxy.URL, proxyA
|
||||||
hc: hc,
|
hc: hc,
|
||||||
blockingClient: blockingClient,
|
blockingClient: blockingClient,
|
||||||
apiServer: apiServer,
|
apiServer: apiServer,
|
||||||
|
hostPort: hostPort,
|
||||||
authHeader: authHeader,
|
authHeader: authHeader,
|
||||||
proxyAuthHeader: proxyAuthHeader,
|
proxyAuthHeader: proxyAuthHeader,
|
||||||
sendFullURL: sendFullURL,
|
sendFullURL: sendFullURL,
|
||||||
|
@ -183,8 +185,8 @@ func (c *Client) getAPIResponseWithParamsAndClient(client *fasthttp.HostClient,
|
||||||
req.SetRequestURIBytes(u.FullURI())
|
req.SetRequestURIBytes(u.FullURI())
|
||||||
} else {
|
} else {
|
||||||
req.SetRequestURIBytes(u.RequestURI())
|
req.SetRequestURIBytes(u.RequestURI())
|
||||||
req.SetHostBytes(u.Host())
|
|
||||||
}
|
}
|
||||||
|
req.Header.SetHost(c.hostPort)
|
||||||
req.Header.Set("Accept-Encoding", "gzip")
|
req.Header.Set("Accept-Encoding", "gzip")
|
||||||
if c.authHeader != "" {
|
if c.authHeader != "" {
|
||||||
req.Header.Set("Authorization", c.authHeader)
|
req.Header.Set("Authorization", c.authHeader)
|
||||||
|
|
Loading…
Reference in a new issue