mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
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:
@ -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()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user