From 9bb2d4f4361ab9b438f0da5527ae8269b7a2ca8f Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Tue, 12 Dec 2017 10:00:04 -0800 Subject: [PATCH] internal/tun2: relay stream body with closer --- internal/tun2/connection.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/internal/tun2/connection.go b/internal/tun2/connection.go index 0490d6c..26851ce 100644 --- a/internal/tun2/connection.go +++ b/internal/tun2/connection.go @@ -2,10 +2,8 @@ package tun2 import ( "bufio" - "bytes" "context" "expvar" - "io/ioutil" "net" "net/http" "time" @@ -143,15 +141,6 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) { if err != nil { return nil, errors.Wrap(err, ErrCantReadResponse.Error()) } - defer resp.Body.Close() - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, errors.Wrap(err, "can't read response body") - } - - resp.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - resp.ContentLength = int64(len(body)) c.counter.Add(1)