Skip to content

Commit

Permalink
clair: reset writers when pulled from pool
Browse files Browse the repository at this point in the history
  • Loading branch information
hdonnay committed Jan 23, 2020
1 parent 0fd9cd3 commit 7b6ef7d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/clair/httpcompress.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ func (c *compressHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case "gzip":
w.Header().Set("content-encoding", "gzip")
gz := c.gzip.Get().(*gzip.Writer)
gz.Reset(w)
defer c.gzip.Put(gz)
cw = gz
case "deflate":
w.Header().Set("content-encoding", "deflate")
z := c.flate.Get().(*flate.Writer)
z.Reset(w)
defer c.flate.Put(z)
cw = z
case "snappy": // Nonstandard
w.Header().Set("content-encoding", "snappy")
s := c.snappy.Get().(*snappy.Writer)
s.Reset(w)
defer c.snappy.Put(s)
cw = s
case "identity":
Expand Down

0 comments on commit 7b6ef7d

Please sign in to comment.