1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Fix for #1164 - allow only one header per line (#1280)

* Fix for #1164 - allow only one header per line

* Include original reporter case
This commit is contained in:
Mateusz Gajewski 2016-11-30 05:24:12 +01:00 committed by Matt Holt
parent 76f12f475b
commit 9e98d6cd52
2 changed files with 21 additions and 5 deletions

View file

@ -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)

View file

@ -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 {