From 99d5acb880180ca548d6e8833bf47d03d06909bb Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Tue, 3 Oct 2017 06:34:09 -0700 Subject: [PATCH] Revert "tun2: connection: do things better" This reverts commit 64524eefc195abe8578f6396c323f173492020c3. re --- internal/tun2/connection.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/tun2/connection.go b/internal/tun2/connection.go index aa79c81..20f05dc 100644 --- a/internal/tun2/connection.go +++ b/internal/tun2/connection.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "io" + "io/ioutil" "net" "net/http" "time" @@ -138,12 +139,20 @@ 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 = &mixedReadCloser{ Reader: buf, Closer: stream, } + resp.ContentLength = int64(len(body)) + return resp, nil }