Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
headers: Fix Caddyfile parsing with request matcher (#3892)
Francis Lavoie committed
Nov 30, 2020 at 12:20 UTC
a26f70a12b1289231d705bc002fe1df3180cb6c5
2 files changed
+29
caddytest/integration/caddyfile_adapt/header.txt
+25
@@ -9,6 +9,10 @@
9
?Tim "Berners-Lee"
10
defer
11
}
12
+ @images path /images/*
13
+ header @images {
14
+ Cache-Control "public, max-age=3600, stale-while-revalidate=86400"
15
+ }
16
}
17
----------
18
{
@@ -20,6 +24,27 @@
24
":80"
25
],
26
"routes": [
27
+ {
28
+ "match": [
29
+ {
30
+ "path": [
31
+ "/images/*"
32
+ ]
33
+ }
34
+ ],
35
+ "handle": [
36
+ {
37
+ "handler": "headers",
38
+ "response": {
39
+ "set": {
40
+ "Cache-Control": [
41
+ "public, max-age=3600, stale-while-revalidate=86400"
42
+ ]
43
+ }
44
+ }
45
+ }
46
+ ]
47
+ },
48
{
49
"handle": [
50
{
modules/caddyhttp/headers/caddyfile.go
+4
@@ -46,6 +46,10 @@ func init() {
46
// and ? conditionally sets a value only if the header field is not already
47
// set.
48
func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
49
+ if !h.Next() {
50
+ return nil, h.ArgErr()
51
+ }
52
+
53
matcherSet, err := h.ExtractMatcherSet()
54
if err != nil {
55
return nil, err