1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00

correctly handle recorded compressed response

see https://github.com/kataras/iris/issues/1569#issuecomment-664003098
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-07-26 20:28:31 +03:00
parent 613d3fc749
commit ad5e5d82ce
3 changed files with 24 additions and 8 deletions

View File

@@ -241,17 +241,22 @@ func releaseCompressResponseWriter(w *CompressResponseWriter) {
// and writes the status code.
// Called automatically before `EndResponse`.
func (w *CompressResponseWriter) FlushResponse() {
w.FlushHeaders()
// write the status, after header set and before any flushed content sent.
w.ResponseWriter.FlushResponse()
w.CompressWriter.Close() // flushes and closes.
}
func (w *CompressResponseWriter) FlushHeaders() {
if w.Disabled {
w.Header().Del(VaryHeaderKey)
w.Header().Del(ContentEncodingHeaderKey)
w.CompressWriter.Reset(&noOpWriter{})
w.CompressWriter.Close()
} else {
w.ResponseWriter.Header().Del(ContentLengthHeaderKey)
w.CompressWriter.Close() // flushes and closes.
}
w.ResponseWriter.FlushResponse()
}
// EndResponse reeases the writers.