Skip to content

Commit 00254cb

Browse files
committed
compiler/natives/src/net/http: Close request body in XHRTransport.
The http.RoundTripper interface (https://godoc.org/net/http#RoundTripper) says: // RoundTrip should not modify the request, except for // consuming and closing the Request's Body. // // RoundTrip must always close the body, including on errors, // but depending on the implementation may do so in a separate // goroutine even after RoundTrip returns. Close request body in XHRTransport.RoundTrip to satisfy the interface contract.
1 parent 621f920 commit 00254cb

File tree

1 file changed

+2
-0
lines changed
  • compiler/natives/src/net/http

1 file changed

+2
-0
lines changed

compiler/natives/src/net/http/http.go

+2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ func (t *XHRTransport) RoundTrip(req *Request) (*Response, error) {
7979
var err error
8080
body, err = ioutil.ReadAll(req.Body)
8181
if err != nil {
82+
req.Body.Close() // RoundTrip must always close the body, including on errors.
8283
return nil, err
8384
}
85+
req.Body.Close()
8486
}
8587
xhr.Call("send", body)
8688

0 commit comments

Comments
 (0)