From 37aa516a6eb5346f5cdcd0ee6a4ec1784c073f54 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 30 Mar 2020 11:52:11 -0600 Subject: headers: Trim any trailing colon from field names as a courtesy --- modules/caddyhttp/headers/caddyfile.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/caddyhttp/headers') diff --git a/modules/caddyhttp/headers/caddyfile.go b/modules/caddyhttp/headers/caddyfile.go index e69c679..d893cab 100644 --- a/modules/caddyhttp/headers/caddyfile.go +++ b/modules/caddyhttp/headers/caddyfile.go @@ -111,6 +111,12 @@ func parseReqHdrCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, return nil, h.ArgErr() } field := h.Val() + + // sometimes it is habitual for users to suffix a field name with a colon, + // as if they were writing a curl command or something; see + // https://caddy.community/t/v2-reverse-proxy-please-add-cors-example-to-the-docs/7349 + field = strings.TrimSuffix(field, ":") + var value, replacement string if h.NextArg() { value = h.Val() -- cgit v1.2.3