Fix default Content-Type for custom-error-pages example

This should fix issue [4039](https://github.com/kubernetes/ingress-nginx/issues/4039). This default backend fails to send the correct `Content-Type` header when it fails to decode the `Accept` request header.

This patch simply forces `text/html` in that specific scenario.
This commit is contained in:
Julio H Morimoto 2019-04-25 14:53:22 -03:00 committed by GitHub
parent 5d31fb2c5d
commit 7245340e88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,7 @@ func errorHandler(path string) func(http.ResponseWriter, *http.Request) {
cext, err := mime.ExtensionsByType(format) cext, err := mime.ExtensionsByType(format)
if err != nil { if err != nil {
log.Printf("unexpected error reading media type extension: %v. Using %v", err, ext) log.Printf("unexpected error reading media type extension: %v. Using %v", err, ext)
format = "text/html"
} else if len(cext) == 0 { } else if len(cext) == 0 {
log.Printf("couldn't get media type extension. Using %v", ext) log.Printf("couldn't get media type extension. Using %v", ext)
} else { } else {