Former-commit-id: aaf275d4eedca95ef8d8f8ef79b1ff2eecf2fbc9
This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-02-03 10:50:58 +02:00
parent 3093d65363
commit d4e38da3ad
2 changed files with 10 additions and 4 deletions

View File

@ -81,9 +81,9 @@ If you discover a security vulnerability within Iris, please send an e-mail to [
## License
The project name "Iris" was inspired by the Greek mythology.
This project is licensed under the [BSD 3-clause license](LICENSE), just like the Go project itself.
Iris Web Framework is free and open-source software licensed under the [3-Clause BSD License](LICENSE).
The project name "Iris" was inspired by the Greek mythology.
## Stargazers over time

View File

@ -1838,12 +1838,16 @@ func (ctx *context) Header(name string, value string) {
const contentTypeContextKey = "_iris_content_type"
func shouldAppendCharset(cType string) bool {
return cType != ContentBinaryHeaderValue && cType != ContentWebassemblyHeaderValue
}
func (ctx *context) contentTypeOnce(cType string, charset string) {
if charset == "" {
charset = ctx.Application().ConfigurationReadOnly().GetCharset()
}
if cType != ContentBinaryHeaderValue {
if shouldAppendCharset(cType) {
cType += "; charset=" + charset
}
@ -1869,7 +1873,7 @@ func (ctx *context) ContentType(cType string) {
}
// if doesn't contain a charset already then append it
if !strings.Contains(cType, "charset") {
if cType != ContentBinaryHeaderValue {
if shouldAppendCharset(cType) {
cType += "; charset=" + ctx.Application().ConfigurationReadOnly().GetCharset()
}
}
@ -3078,6 +3082,8 @@ func (ctx *context) View(filename string, optionalViewModel ...interface{}) erro
const (
// ContentBinaryHeaderValue header value for binary data.
ContentBinaryHeaderValue = "application/octet-stream"
// ContentWebassemblyHeaderValue header value for web assembly files.
ContentWebassemblyHeaderValue = "application/wasm"
// ContentHTMLHeaderValue is the string of text/html response header's content type value.
ContentHTMLHeaderValue = "text/html"
// ContentJSONHeaderValue header value for JSON data.