mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/httpserver: do not flush and do not close gzip writer if response compression is disabled
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/535
This commit is contained in:
parent
c1be462d42
commit
9f55dea162
1 changed files with 11 additions and 6 deletions
|
@ -336,11 +336,13 @@ func (zrw *gzipResponseWriter) writeHeader() {
|
||||||
|
|
||||||
// Implements http.Flusher
|
// Implements http.Flusher
|
||||||
func (zrw *gzipResponseWriter) Flush() {
|
func (zrw *gzipResponseWriter) Flush() {
|
||||||
if err := zrw.bw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
if !zrw.disableCompression {
|
||||||
logger.Warnf("gzipResponseWriter.Flush (buffer): %s", err)
|
if err := zrw.bw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
||||||
}
|
logger.Warnf("gzipResponseWriter.Flush (buffer): %s", err)
|
||||||
if err := zrw.zw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
}
|
||||||
logger.Warnf("gzipResponseWriter.Flush (gzip): %s", err)
|
if err := zrw.zw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
||||||
|
logger.Warnf("gzipResponseWriter.Flush (gzip): %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if fw, ok := zrw.ResponseWriter.(http.Flusher); ok {
|
if fw, ok := zrw.ResponseWriter.(http.Flusher); ok {
|
||||||
fw.Flush()
|
fw.Flush()
|
||||||
|
@ -353,7 +355,10 @@ func (zrw *gzipResponseWriter) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
zrw.Flush()
|
zrw.Flush()
|
||||||
err := zrw.zw.Close()
|
var err error
|
||||||
|
if !zrw.disableCompression {
|
||||||
|
err = zrw.zw.Close()
|
||||||
|
}
|
||||||
putGzipWriter(zrw.zw)
|
putGzipWriter(zrw.zw)
|
||||||
zrw.zw = nil
|
zrw.zw = nil
|
||||||
putBufioWriter(zrw.bw)
|
putBufioWriter(zrw.bw)
|
||||||
|
|
Loading…
Reference in a new issue