mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-31 02:55:17 -04:00
Allow multiple values for an HTTP header and
add a test to ensure this works.
This commit is contained in:
@@ -24,8 +24,12 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
|
||||
for _, rule := range h.Rules {
|
||||
if httpserver.Path(r.URL.Path).Matches(rule.Path) {
|
||||
for _, header := range rule.Headers {
|
||||
// One can either delete a header, add multiple values to a header, or simply
|
||||
// set a header.
|
||||
if strings.HasPrefix(header.Name, "-") {
|
||||
w.Header().Del(strings.TrimLeft(header.Name, "-"))
|
||||
} else if strings.HasPrefix(header.Name, "+") {
|
||||
w.Header().Add(strings.TrimLeft(header.Name, "+"), replacer.Replace(header.Value))
|
||||
} else {
|
||||
w.Header().Set(header.Name, replacer.Replace(header.Value))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user