api: close gzip writer to flush it

This commit is contained in:
Quentin Machu 2016-02-12 17:25:11 -05:00 committed by Jimmy Zelinskie
parent c2605e0bf2
commit 0e9a7e1740

View File

@ -67,7 +67,10 @@ func writeResponse(w http.ResponseWriter, r *http.Request, status int, resp inte
// Gzip the response if the client supports it. // Gzip the response if the client supports it.
var writer io.Writer = w var writer io.Writer = w
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
writer = gzip.NewWriter(w) gzipWriter := gzip.NewWriter(w)
defer gzipWriter.Close()
writer = gzipWriter
header.Set("Content-Encoding", "gzip") header.Set("Content-Encoding", "gzip")
} }