1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

don't force-set content type on gzip response writer's WriteString and Writef if already there

Former-commit-id: c882a6ef14e89dd0da7a3a2afc85100ca07dc869
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-02-06 11:55:56 +02:00
parent e523d08cb1
commit 431e339ccc
2 changed files with 8 additions and 3 deletions

View File

@@ -117,7 +117,9 @@ func (w *GzipResponseWriter) Write(contents []byte) (int, error) {
func (w *GzipResponseWriter) Writef(format string, a ...interface{}) (n int, err error) {
n, err = fmt.Fprintf(w, format, a...)
if err == nil {
w.ResponseWriter.Header().Set(contentTypeHeaderKey, ContentTextHeaderValue)
if w.ResponseWriter.Header()[contentTypeHeaderKey] == nil {
w.ResponseWriter.Header().Set(contentTypeHeaderKey, ContentTextHeaderValue)
}
}
return
@@ -128,7 +130,10 @@ func (w *GzipResponseWriter) Writef(format string, a ...interface{}) (n int, err
func (w *GzipResponseWriter) WriteString(s string) (n int, err error) {
n, err = w.Write([]byte(s))
if err == nil {
w.ResponseWriter.Header().Set(contentTypeHeaderKey, ContentTextHeaderValue)
if w.ResponseWriter.Header()[contentTypeHeaderKey] == nil {
w.ResponseWriter.Header().Set(contentTypeHeaderKey, ContentTextHeaderValue)
}
}
return
}