Skip to content

Commit 4b2bd96

Browse files
authored
make sure zstd decomp closes (#25)
* make sure zstd decomp closes * remove debugging tools
1 parent c47dfe4 commit 4b2bd96

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

proxy/proxy.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ func init() {
3737
}
3838
}
3939

40+
type zstdCloser struct {
41+
*zstd.Decoder
42+
}
43+
44+
func (zc *zstdCloser) Close() error {
45+
zc.Decoder.Close()
46+
return nil
47+
}
48+
4049
func Decompress(rdr io.ReadCloser, encoding string) (io.ReadCloser, error) {
4150
switch encoding {
4251
case "gzip":
@@ -51,7 +60,8 @@ func Decompress(rdr io.ReadCloser, encoding string) (io.ReadCloser, error) {
5160
if err != nil {
5261
return nil, err
5362
}
54-
return io.NopCloser(decomp), nil
63+
// else we leak
64+
return &zstdCloser{Decoder: decomp}, nil
5565
default:
5666
return rdr, nil
5767
}

0 commit comments

Comments
 (0)