tstest/integration: stop leaking zstd.Decoders

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
pull/3465/head
Josh Bleecher Snyder 3 years ago committed by Josh Bleecher Snyder
parent 124363e0ca
commit b800663779

@ -29,6 +29,7 @@ import (
"testing"
"time"
"github.com/klauspost/compress/zstd"
"go4.org/mem"
"tailscale.com/derp"
"tailscale.com/derp/derphttp"
@ -239,12 +240,15 @@ func (lc *LogCatcher) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var body io.Reader = r.Body
if r.Header.Get("Content-Encoding") == "zstd" {
var err error
body, err = smallzstd.NewDecoder(body)
var dec *zstd.Decoder
dec, err = smallzstd.NewDecoder(body)
if err != nil {
log.Printf("bad caught zstd: %v", err)
http.Error(w, err.Error(), 400)
return
}
defer dec.Close()
body = dec
}
bodyBytes, _ := ioutil.ReadAll(body)

Loading…
Cancel
Save