mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
correctly handle recorded compressed response
see https://github.com/kataras/iris/issues/1569#issuecomment-664003098
This commit is contained in:
@@ -152,14 +152,24 @@ func (w *ResponseRecorder) FlushResponse() {
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: before the ResponseWriter.Write in order to:
|
||||
// set the given status code even if the body is empty.
|
||||
w.ResponseWriter.FlushResponse()
|
||||
cw, mustWriteToClose := w.ResponseWriter.(*CompressResponseWriter)
|
||||
if mustWriteToClose { // see #1569#issuecomment-664003098
|
||||
cw.FlushHeaders()
|
||||
} else {
|
||||
// NOTE: before the ResponseWriter.Write in order to:
|
||||
// set the given status code even if the body is empty.
|
||||
w.ResponseWriter.FlushResponse()
|
||||
}
|
||||
|
||||
if len(w.chunks) > 0 {
|
||||
// ignore error
|
||||
w.ResponseWriter.Write(w.chunks)
|
||||
}
|
||||
|
||||
if mustWriteToClose {
|
||||
cw.CompressWriter.Close()
|
||||
cw.ResponseWriter.FlushResponse()
|
||||
}
|
||||
}
|
||||
|
||||
// Clone returns a clone of this response writer
|
||||
|
||||
Reference in New Issue
Block a user