diff --git a/caddyhttp/header/setup.go b/caddyhttp/header/setup.go index 18ba944b7..61cd06042 100644 --- a/caddyhttp/header/setup.go +++ b/caddyhttp/header/setup.go @@ -60,8 +60,12 @@ func headersParse(c *caddy.Controller) ([]Rule, error) { name := c.Val() value := "" - if c.NextArg() { - value = c.Val() + args := c.RemainingArgs() + + if len(args) > 1 { + return rules, c.ArgErr() + } else if len(args) == 1 { + value = args[0] } head.Headers.Add(name, value) diff --git a/caddyhttp/header/setup_test.go b/caddyhttp/header/setup_test.go index c1591bfed..da40bca96 100644 --- a/caddyhttp/header/setup_test.go +++ b/caddyhttp/header/setup_test.go @@ -45,13 +45,25 @@ func TestHeadersParse(t *testing.T) { "Foo": []string{"Bar Baz"}, }}, }}, - {`header /bar { Foo "Bar Baz" Baz Qux }`, + {`header /bar { + Foo "Bar Baz" + Baz Qux + Foobar + }`, false, []Rule{ {Path: "/bar", Headers: http.Header{ - "Foo": []string{"Bar Baz"}, - "Baz": []string{"Qux"}, + "Foo": []string{"Bar Baz"}, + "Baz": []string{"Qux"}, + "Foobar": []string{""}, }}, }}, + {`header /foo { + Foo Bar Baz + }`, true, + []Rule{}}, + {`header /foo { + Test "max-age=1814400"; + }`, true, []Rule{}}, } for i, test := range tests {