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

2
Gopkg.lock generated
View File

@ -170,7 +170,7 @@
revision = "abc90934186a77966e2beeac62ed966aac0561d5"
[[projects]]
branch = "master"
branch = "v1.2.0"
name = "github.com/satori/go.uuid"
packages = ["."]
revision = "f58768cc1a7a7e77a3bd49e98cdd21419399b6a3"

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
}