Closes the compressedResponseWriter and ensures to flush all data before.
()
| 34 | |
| 35 | // Closes the compressedResponseWriter and ensures to flush all data before. |
| 36 | func (c *compressedResponseWriter) Close() { |
| 37 | if zstdWriter, ok := c.writer.(*zstd.Encoder); ok { |
| 38 | zstdWriter.Flush() |
| 39 | } |
| 40 | if snappyWriter, ok := c.writer.(*snappy.Writer); ok { |
| 41 | snappyWriter.Flush() |
| 42 | } |
| 43 | if zlibWriter, ok := c.writer.(*zlib.Writer); ok { |
| 44 | zlibWriter.Flush() |
| 45 | } |
| 46 | if gzipWriter, ok := c.writer.(*gzip.Writer); ok { |
| 47 | gzipWriter.Flush() |
| 48 | } |
| 49 | if closer, ok := c.writer.(io.Closer); ok { |
| 50 | defer closer.Close() |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | // Constructs a new compressedResponseWriter based on client request headers. |
| 55 | func newCompressedResponseWriter(writer http.ResponseWriter, req *http.Request) *compressedResponseWriter { |