caddyhttp: Canonicalize header field names (#5176)

This commit is contained in:
Alexander Graf 2022-10-29 22:35:44 +02:00 committed by GitHub
parent 1fa4cb7ba1
commit 087f126cf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,7 @@ import (
"fmt"
"io"
"net/http"
"net/textproto"
"os"
"strconv"
"strings"
@ -193,7 +194,7 @@ func (s StaticResponse) ServeHTTP(w http.ResponseWriter, r *http.Request, next H
// set all headers
for field, vals := range s.Headers {
field = repl.ReplaceAll(field, "")
field = textproto.CanonicalMIMEHeaderKey(repl.ReplaceAll(field, ""))
newVals := make([]string, len(vals))
for i := range vals {
newVals[i] = repl.ReplaceAll(vals[i], "")