diff --git a/tunnel/connection.go b/tunnel/connection.go index e48167f2..1f9f335b 100644 --- a/tunnel/connection.go +++ b/tunnel/connection.go @@ -36,6 +36,7 @@ func (t *Tunnel) handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) { if err != nil { break } + defer resp.Body.Close() adapters.RemoveHopByHopHeaders(resp.Header) if resp.StatusCode == http.StatusContinue { @@ -59,6 +60,13 @@ func (t *Tunnel) handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) { break } + buf := pool.BufPool.Get().([]byte) + _, err = io.CopyBuffer(request, resp.Body, buf) + pool.BufPool.Put(buf[:cap(buf)]) + if err != nil && err != io.EOF { + break + } + req, err = http.ReadRequest(inboundReeder) if err != nil { break