mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 12:31:58 +00:00
fix #1531 and introduce the 'Configuration.ResetOnFireErrorCode' (read HISTORY.md)
Former-commit-id: 84f1e894378a6dfd94e0bf057f4037e35aee0c4f
This commit is contained in:
@@ -117,8 +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 {
|
||||
if w.ResponseWriter.Header()[ContentTypeHeaderKey] == nil {
|
||||
w.ResponseWriter.Header().Set(ContentTypeHeaderKey, ContentTextHeaderValue)
|
||||
h := w.ResponseWriter.Header()
|
||||
if h[ContentTypeHeaderKey] == nil {
|
||||
h.Set(ContentTypeHeaderKey, ContentTextHeaderValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +131,9 @@ 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 {
|
||||
if w.ResponseWriter.Header()[ContentTypeHeaderKey] == nil {
|
||||
w.ResponseWriter.Header().Set(ContentTypeHeaderKey, ContentTextHeaderValue)
|
||||
h := w.ResponseWriter.Header()
|
||||
if h[ContentTypeHeaderKey] == nil {
|
||||
h.Set(ContentTypeHeaderKey, ContentTextHeaderValue)
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -183,11 +185,10 @@ func AddGzipHeaders(w ResponseWriter) {
|
||||
w.Header().Add(ContentEncodingHeaderKey, GzipHeaderValue)
|
||||
}
|
||||
|
||||
// FlushResponse validates the response headers in order to be compatible with the gzip written data
|
||||
// and writes the data to the underline ResponseWriter.
|
||||
func (w *GzipResponseWriter) FlushResponse() {
|
||||
_, _ = w.WriteNow(w.chunks)
|
||||
w.ResponseWriter.FlushResponse()
|
||||
// Body returns the body tracked from the writer so far,
|
||||
// do not use this for edit.
|
||||
func (w *GzipResponseWriter) Body() []byte {
|
||||
return w.chunks
|
||||
}
|
||||
|
||||
// ResetBody resets the response body.
|
||||
@@ -200,3 +201,10 @@ func (w *GzipResponseWriter) ResetBody() {
|
||||
func (w *GzipResponseWriter) Disable() {
|
||||
w.disabled = true
|
||||
}
|
||||
|
||||
// FlushResponse validates the response headers in order to be compatible with the gzip written data
|
||||
// and writes the data to the underline ResponseWriter.
|
||||
func (w *GzipResponseWriter) FlushResponse() {
|
||||
_, _ = w.WriteNow(w.chunks)
|
||||
w.ResponseWriter.FlushResponse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user