Skip to content

Commit

Permalink
headers: Fix Caddyfile parsing with request matcher (#3892)
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Nov 30, 2020
1 parent 4afcdc4 commit a26f70a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions caddytest/integration/caddyfile_adapt/header.txt
Expand Up @@ -9,6 +9,10 @@
?Tim "Berners-Lee"
defer
}
@images path /images/*
header @images {
Cache-Control "public, max-age=3600, stale-while-revalidate=86400"
}
}
----------
{
Expand All @@ -20,6 +24,27 @@
":80"
],
"routes": [
{
"match": [
{
"path": [
"/images/*"
]
}
],
"handle": [
{
"handler": "headers",
"response": {
"set": {
"Cache-Control": [
"public, max-age=3600, stale-while-revalidate=86400"
]
}
}
}
]
},
{
"handle": [
{
Expand Down
4 changes: 4 additions & 0 deletions modules/caddyhttp/headers/caddyfile.go
Expand Up @@ -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
Expand Down

0 comments on commit a26f70a

Please sign in to comment.