Remove hop headers

Requested by @LucasRoesler - removes headers detailed in HTTP
spec which are not supposed to be forwarded by proxies or
gateways.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2019-04-03 11:41:02 +01:00
parent af73147ef8
commit 78c127619e
2 changed files with 43 additions and 0 deletions

View File

@ -338,3 +338,22 @@ func Test_buildUpstreamRequest_WithPathAndQuery(t *testing.T) {
}
}
func Test_deleteHeaders(t *testing.T) {
h := http.Header{}
target := "X-Dont-Forward"
h.Add(target, "value1")
h.Add("X-Keep-This", "value2")
deleteHeaders(&h, &[]string{target})
if h.Get(target) == "value1" {
t.Errorf("want %s to be removed from headers", target)
t.Fail()
}
if h.Get("X-Keep-This") != "value2" {
t.Errorf("want %s to remain in headers", "X-Keep-This")
t.Fail()
}
}