Skip to content

Commit

Permalink
make sure zstd decomp closes (#25)
Browse files Browse the repository at this point in the history
* make sure zstd decomp closes

* remove debugging tools
  • Loading branch information
seiflotfy authored Nov 11, 2021
1 parent c47dfe4 commit 4b2bd96
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ func init() {
}
}

type zstdCloser struct {
*zstd.Decoder
}

func (zc *zstdCloser) Close() error {
zc.Decoder.Close()
return nil
}

func Decompress(rdr io.ReadCloser, encoding string) (io.ReadCloser, error) {
switch encoding {
case "gzip":
Expand All @@ -51,7 +60,8 @@ func Decompress(rdr io.ReadCloser, encoding string) (io.ReadCloser, error) {
if err != nil {
return nil, err
}
return io.NopCloser(decomp), nil
// else we leak
return &zstdCloser{Decoder: decomp}, nil
default:
return rdr, nil
}
Expand Down

0 comments on commit 4b2bd96

Please # to comment.