Skip to content

Commit

Permalink
fix #1440
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Feb 3, 2020
1 parent 8a723bd commit d107161
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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()
}
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d107161

Please sign in to comment.