summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--caddytest/integration/caddyfile_adapt/header.txt25
-rw-r--r--modules/caddyhttp/headers/caddyfile.go4
2 files changed, 29 insertions, 0 deletions
diff --git a/caddytest/integration/caddyfile_adapt/header.txt b/caddytest/integration/caddyfile_adapt/header.txt
index b8e102f..19a5b41 100644
--- a/caddytest/integration/caddyfile_adapt/header.txt
+++ b/caddytest/integration/caddyfile_adapt/header.txt
@@ -9,6 +9,10 @@
?Tim "Berners-Lee"
defer
}
+ @images path /images/*
+ header @images {
+ Cache-Control "public, max-age=3600, stale-while-revalidate=86400"
+ }
}
----------
{
@@ -21,6 +25,27 @@
],
"routes": [
{
+ "match": [
+ {
+ "path": [
+ "/images/*"
+ ]
+ }
+ ],
+ "handle": [
+ {
+ "handler": "headers",
+ "response": {
+ "set": {
+ "Cache-Control": [
+ "public, max-age=3600, stale-while-revalidate=86400"
+ ]
+ }
+ }
+ }
+ ]
+ },
+ {
"handle": [
{
"handler": "headers",
diff --git a/modules/caddyhttp/headers/caddyfile.go b/modules/caddyhttp/headers/caddyfile.go
index 75498b2..574e54b 100644
--- a/modules/caddyhttp/headers/caddyfile.go
+++ b/modules/caddyhttp/headers/caddyfile.go
@@ -46,6 +46,10 @@ func init() {
// and ? conditionally sets a value only if the header field is not already
// set.
func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
+ if !h.Next() {
+ return nil, h.ArgErr()
+ }
+
matcherSet, err := h.ExtractMatcherSet()
if err != nil {
return nil, err