headers: Trim any trailing colon from field names as a courtesy

This commit is contained in:
Matthew Holt 2020-03-30 11:52:11 -06:00
parent 105acfa086
commit 37aa516a6e
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
1 changed files with 6 additions and 0 deletions

View File

@ -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()