mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +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
ab9e1eb41f
commit
dd19fab7c9
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)
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(c.requestURI)
|
||||
req.SetHost(c.host)
|
||||
req.Header.SetHost(c.host)
|
||||
// The following `Accept` header has been copied from Prometheus sources.
|
||||
// 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.
|
||||
|
|
|
@ -42,6 +42,7 @@ type Client struct {
|
|||
|
||||
apiServer string
|
||||
|
||||
hostPort string
|
||||
authHeader string
|
||||
proxyAuthHeader string
|
||||
sendFullURL bool
|
||||
|
@ -127,6 +128,7 @@ func NewClient(apiServer string, ac *promauth.Config, proxyURL proxy.URL, proxyA
|
|||
hc: hc,
|
||||
blockingClient: blockingClient,
|
||||
apiServer: apiServer,
|
||||
hostPort: hostPort,
|
||||
authHeader: authHeader,
|
||||
proxyAuthHeader: proxyAuthHeader,
|
||||
sendFullURL: sendFullURL,
|
||||
|
@ -183,8 +185,8 @@ func (c *Client) getAPIResponseWithParamsAndClient(client *fasthttp.HostClient,
|
|||
req.SetRequestURIBytes(u.FullURI())
|
||||
} else {
|
||||
req.SetRequestURIBytes(u.RequestURI())
|
||||
req.SetHostBytes(u.Host())
|
||||
}
|
||||
req.Header.SetHost(c.hostPort)
|
||||
req.Header.Set("Accept-Encoding", "gzip")
|
||||
if c.authHeader != "" {
|
||||
req.Header.Set("Authorization", c.authHeader)
|
||||
|
|
Loading…
Reference in a new issue