From 6cc17af6589fa049743feb23badb5c1ff2e7da26 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Thu, 6 May 2021 22:34:37 +0800 Subject: [PATCH] Fix: HTTP inbound leak --- tunnel/connection.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tunnel/connection.go b/tunnel/connection.go index 1aba6238..fe1e72b2 100644 --- a/tunnel/connection.go +++ b/tunnel/connection.go @@ -29,9 +29,9 @@ func handleHTTP(ctx *context.HTTPContext, outbound net.Conn) { for { keepAlive := strings.TrimSpace(strings.ToLower(req.Header.Get("Proxy-Connection"))) == "keep-alive" - req.Header.Set("Connection", "close") req.RequestURI = "" inbound.RemoveHopByHopHeaders(req.Header) + req.Header.Set("Connection", "close") err := req.Write(outbound) if err != nil { break @@ -72,14 +72,6 @@ func handleHTTP(ctx *context.HTTPContext, outbound net.Conn) { break } - // even if resp.Write write body to the connection, but some http request have to Copy to close it - buf := pool.Get(pool.RelayBufferSize) - _, err = io.CopyBuffer(conn, resp.Body, buf) - pool.Put(buf) - if err != nil && err != io.EOF { - break - } - req, err = http.ReadRequest(inboundReader) if err != nil { break