From 88d0a0a619091bccb6e27b6bbde19af4704e195b Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Tue, 3 Oct 2017 06:34:21 -0700 Subject: [PATCH] Revert "internal/tun2: forward stream buffered reader and closer to response bodies" This reverts commit 223b816f888ee29d079085396f9710b3f39bcc96. --- internal/tun2/connection.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/internal/tun2/connection.go b/internal/tun2/connection.go index 20f05dc..9db2195 100644 --- a/internal/tun2/connection.go +++ b/internal/tun2/connection.go @@ -2,8 +2,8 @@ package tun2 import ( "bufio" + "bytes" "context" - "io" "io/ioutil" "net" "net/http" @@ -127,6 +127,7 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) { if err != nil { return nil, errors.Wrap(err, ErrCantOpenSessionStream.Error()) } + defer stream.Close() err = req.Write(stream) if err != nil { @@ -146,17 +147,8 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) { return nil, errors.Wrap(err, "can't read response body") } - resp.Body = &mixedReadCloser{ - Reader: buf, - Closer: stream, - } - + resp.Body = ioutil.NopCloser(bytes.NewBuffer(body)) resp.ContentLength = int64(len(body)) return resp, nil } - -type mixedReadCloser struct { - io.Reader - io.Closer -}