mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 22:40:31 -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()
|
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) {
|
||||||
"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 {
|
||||||
|
|
Loading…
Reference in a new issue