Fix: close http Response body on provider (#1154)

This commit is contained in:
gVisor bot 2020-12-29 11:28:22 +08:00
parent 73c7b86477
commit b283869c72
3 changed files with 4 additions and 0 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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