Skip to content

Commit

Permalink
[FIX] We must close gzip.Reader, only if no error (labstack#1069)
Browse files Browse the repository at this point in the history
* [FIX] We must close gzip.Reader, only if no error
* review comments fix
  • Loading branch information
im-kulikov authored and vishr committed Feb 23, 2018
1 parent 4f3080c commit 6da0483
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions middleware/compress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ func TestGzipWithStatic(t *testing.T) {
assert.Equal(t, cl, rec.Body.Len())
}
r, err := gzip.NewReader(rec.Body)
assert.NoError(t, err)
defer r.Close()
want, err := ioutil.ReadFile("../_fixture/images/walle.png")
if assert.NoError(t, err) {
buf := new(bytes.Buffer)
buf.ReadFrom(r)
assert.Equal(t, want, buf.Bytes())
defer r.Close()
want, err := ioutil.ReadFile("../_fixture/images/walle.png")
if assert.NoError(t, err) {
buf := new(bytes.Buffer)
buf.ReadFrom(r)
assert.Equal(t, want, buf.Bytes())
}
}
}

0 comments on commit 6da0483

Please sign in to comment.