Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2203: omit the charset attribute when Content-Type is text/html #6743

Merged
merged 7 commits into from
Dec 2, 2019
Merged
9 changes: 9 additions & 0 deletions core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam
}
}

buf := make([]byte, 512)
_, _ = content.Read(buf)
djalilhebal marked this conversation as resolved.
Show resolved Hide resolved
mime := http.DetectContentType(buf)

if strings.HasPrefix(mime, "text/html;") {
mime = "text/html"
}
w.Header().Set("Content-Type", mime)
djalilhebal marked this conversation as resolved.
Show resolved Hide resolved

http.ServeContent(w, req, name, modtime, content)
djalilhebal marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down