Skip to content

Commit

Permalink
Fix: HTTP proxy should copy body
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Oct 26, 2019
1 parent 65f4a35 commit 52cfa94
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tunnel/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 52cfa94

Please sign in to comment.