Custom Error Pages: Accept first of many MIME types. (#13006)

Co-authored-by: Jeremy Ebler <jebler@gmail.com>
This commit is contained in:
k8s-infra-cherrypick-robot 2025-03-22 03:40:31 -07:00 committed by GitHub
parent 4b34d134a6
commit f051ca3b3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -126,6 +126,12 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re
log.Printf("format not specified. Using %v", format)
}
// if multiple formats are provided, use the first one
index := strings.Index(format, ",")
if index != -1 {
format = format[:index]
}
cext, err := mime.ExtensionsByType(format)
if err != nil {
log.Printf("unexpected error reading media type extension: %v. Using %v", err, ext)