tstest/integration: stop leaking zstd.Decoders
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
124363e0ca
commit
b800663779
|
@ -29,6 +29,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/klauspost/compress/zstd"
|
||||||
"go4.org/mem"
|
"go4.org/mem"
|
||||||
"tailscale.com/derp"
|
"tailscale.com/derp"
|
||||||
"tailscale.com/derp/derphttp"
|
"tailscale.com/derp/derphttp"
|
||||||
|
@ -239,12 +240,15 @@ func (lc *LogCatcher) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
var body io.Reader = r.Body
|
var body io.Reader = r.Body
|
||||||
if r.Header.Get("Content-Encoding") == "zstd" {
|
if r.Header.Get("Content-Encoding") == "zstd" {
|
||||||
var err error
|
var err error
|
||||||
body, err = smallzstd.NewDecoder(body)
|
var dec *zstd.Decoder
|
||||||
|
dec, err = smallzstd.NewDecoder(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("bad caught zstd: %v", err)
|
log.Printf("bad caught zstd: %v", err)
|
||||||
http.Error(w, err.Error(), 400)
|
http.Error(w, err.Error(), 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer dec.Close()
|
||||||
|
body = dec
|
||||||
}
|
}
|
||||||
bodyBytes, _ := ioutil.ReadAll(body)
|
bodyBytes, _ := ioutil.ReadAll(body)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue