Commit 9e98d6cd authored by Mateusz Gajewski's avatar Mateusz Gajewski Committed by Matt Holt

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

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

* Include original reporter case
parent 76f12f47
...@@ -60,8 +60,12 @@ func headersParse(c *caddy.Controller) ([]Rule, error) { ...@@ -60,8 +60,12 @@ func headersParse(c *caddy.Controller) ([]Rule, error) {
name := c.Val() name := c.Val()
value := "" value := ""
if c.NextArg() { args := c.RemainingArgs()
value = c.Val()
if len(args) > 1 {
return rules, c.ArgErr()
} else if len(args) == 1 {
value = args[0]
} }
head.Headers.Add(name, value) head.Headers.Add(name, value)
......
...@@ -45,13 +45,25 @@ func TestHeadersParse(t *testing.T) { ...@@ -45,13 +45,25 @@ func TestHeadersParse(t *testing.T) {
"Foo": []string{"Bar Baz"}, "Foo": []string{"Bar Baz"},
}}, }},
}}, }},
{`header /bar { Foo "Bar Baz" Baz Qux }`, {`header /bar {
Foo "Bar Baz"
Baz Qux
Foobar
}`,
false, []Rule{ false, []Rule{
{Path: "/bar", Headers: http.Header{ {Path: "/bar", Headers: http.Header{
"Foo": []string{"Bar Baz"}, "Foo": []string{"Bar Baz"},
"Baz": []string{"Qux"}, "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 { for i, test := range tests {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment