summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/matchers.go4
-rw-r--r--modules/caddyhttp/matchers_test.go10
2 files changed, 14 insertions, 0 deletions
diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go
index b7a304f..d641cb6 100644
--- a/modules/caddyhttp/matchers.go
+++ b/modules/caddyhttp/matchers.go
@@ -445,6 +445,10 @@ func matchHeaders(input, against http.Header, host string) bool {
// match if the header field exists at all
continue
}
+ if allowedFieldVals == nil && actualFieldVals == nil {
+ // a nil list means match if the header does not exist at all
+ continue
+ }
var match bool
fieldVals:
for _, actualFieldVal := range actualFieldVals {
diff --git a/modules/caddyhttp/matchers_test.go b/modules/caddyhttp/matchers_test.go
index 9a2836d..51db67d 100644
--- a/modules/caddyhttp/matchers_test.go
+++ b/modules/caddyhttp/matchers_test.go
@@ -480,6 +480,16 @@ func TestHeaderMatcher(t *testing.T) {
host: "caddyserver.com",
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}
actual := tc.match.Match(req)