diff --git a/adapters/provider/vehicle.go b/adapters/provider/vehicle.go index 175f50ce..13d898fc 100644 --- a/adapters/provider/vehicle.go +++ b/adapters/provider/vehicle.go @@ -107,6 +107,7 @@ func (h *HTTPVehicle) Read() ([]byte, error) { if err != nil { return nil, err } + defer resp.Body.Close() buf, err := ioutil.ReadAll(resp.Body) if err != nil { diff --git a/component/vmess/h2.go b/component/vmess/h2.go index b814ae9b..2c4c47fa 100644 --- a/component/vmess/h2.go +++ b/component/vmess/h2.go @@ -46,6 +46,7 @@ func (hc *h2Conn) establishConn() error { }, } + // it will be close at : `func (hc *h2Conn) Close() error` res, err := hc.ClientConn.RoundTrip(&req) if err != nil { return err diff --git a/tunnel/connection.go b/tunnel/connection.go index 1e8ee1df..15a62555 100644 --- a/tunnel/connection.go +++ b/tunnel/connection.go @@ -34,6 +34,8 @@ func handleHTTP(request *inbound.HTTPAdapter, outbound net.Conn) { } handleResponse: + // resp will be closed after we call resp.Write() + // see https://golang.org/pkg/net/http/#Response.Write resp, err := http.ReadResponse(outboundReader, req) if err != nil { break