From a5a90fe6fc51c3d9988d6e699cf27cd2b66f7be6 Mon Sep 17 00:00:00 2001 From: stanislavromanov Date: Fri, 8 May 2015 17:43:32 +0200 Subject: [PATCH] close #64 --- middleware/headers/headers.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/middleware/headers/headers.go b/middleware/headers/headers.go index 4c6f424f..7e3d6dbb 100644 --- a/middleware/headers/headers.go +++ b/middleware/headers/headers.go @@ -5,6 +5,7 @@ package headers import ( "net/http" + "strings" "github.com/mholt/caddy/middleware" ) @@ -22,7 +23,11 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) for _, rule := range h.Rules { if middleware.Path(r.URL.Path).Matches(rule.Url) { for _, header := range rule.Headers { - w.Header().Set(header.Name, header.Value) + if strings.HasPrefix(header.Name, "-") { + w.Header().Del(strings.TrimLeft(header.Name, "-")) + } else { + w.Header().Set(header.Name, header.Value) + } } } }