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 * Include original reporter case
This commit is contained in:
parent
76f12f475b
commit
9e98d6cd52
2 changed files with 21 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue