mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-19 10:32:45 +08:00
parent
99b8f44486
commit
4fc570711e
|
@ -445,6 +445,10 @@ func matchHeaders(input, against http.Header, host string) bool {
|
||||||
// match if the header field exists at all
|
// match if the header field exists at all
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if allowedFieldVals == nil && actualFieldVals == nil {
|
||||||
|
// a nil list means match if the header does not exist at all
|
||||||
|
continue
|
||||||
|
}
|
||||||
var match bool
|
var match bool
|
||||||
fieldVals:
|
fieldVals:
|
||||||
for _, actualFieldVal := range actualFieldVals {
|
for _, actualFieldVal := range actualFieldVals {
|
||||||
|
|
|
@ -480,6 +480,16 @@ func TestHeaderMatcher(t *testing.T) {
|
||||||
host: "caddyserver.com",
|
host: "caddyserver.com",
|
||||||
expect: false,
|
expect: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
match: MatchHeader{"Must-Not-Exist": nil},
|
||||||
|
input: http.Header{},
|
||||||
|
expect: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: MatchHeader{"Must-Not-Exist": nil},
|
||||||
|
input: http.Header{"Must-Not-Exist": []string{"do not match"}},
|
||||||
|
expect: false,
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
req := &http.Request{Header: tc.input, Host: tc.host}
|
req := &http.Request{Header: tc.input, Host: tc.host}
|
||||||
actual := tc.match.Match(req)
|
actual := tc.match.Match(req)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user