mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 00:32:21 +08:00
Chore: Use Header.Set method instead of Header.Add (#29804)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@ -11,9 +11,9 @@ func TestPrepareProxyRequest(t *testing.T) {
|
||||
t.Run("Prepare proxy request should clear X-Forwarded headers", func(t *testing.T) {
|
||||
req, err := http.NewRequest(http.MethodGet, "/", nil)
|
||||
require.NoError(t, err)
|
||||
req.Header.Add("X-Forwarded-Host", "host")
|
||||
req.Header.Add("X-Forwarded-Port", "123")
|
||||
req.Header.Add("X-Forwarded-Proto", "http1")
|
||||
req.Header.Set("X-Forwarded-Host", "host")
|
||||
req.Header.Set("X-Forwarded-Port", "123")
|
||||
req.Header.Set("X-Forwarded-Proto", "http1")
|
||||
|
||||
PrepareProxyRequest(req)
|
||||
require.NotContains(t, req.Header, "X-Forwarded-Host")
|
||||
@ -34,7 +34,7 @@ func TestPrepareProxyRequest(t *testing.T) {
|
||||
t.Run("Prepare proxy request should append client ip at the end of X-Forwarded-For", func(t *testing.T) {
|
||||
req, err := http.NewRequest(http.MethodGet, "/", nil)
|
||||
req.RemoteAddr = "127.0.0.1:1234"
|
||||
req.Header.Add("X-Forwarded-For", "192.168.0.1")
|
||||
req.Header.Set("X-Forwarded-For", "192.168.0.1")
|
||||
require.NoError(t, err)
|
||||
|
||||
PrepareProxyRequest(req)
|
||||
|
Reference in New Issue
Block a user