bodyclose icon indicating copy to clipboard operation
bodyclose copied to clipboard

Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.

Results 37 bodyclose issues
Sort by recently updated
recently updated
newest added

Here is the sample code to reproduce: ```go package main import ( "net/http" ) func getResponse(url string) *http.Response { res, _ := http.Get(url) return res } func main() { resp...

The following code triggers a false positive. ```golang package util import ( "io" "log" ) func Close(c io.Closer) { if err := c.Close(); err != nil { log.Printf("error closing io:...

``` var resp *http.Response func testGlobal() { resp, _ = http.Get("https://example.com") resp.Body.Close() } ``` It cause panic when check this code. ``` ERRO [runner] Panic: bodyclose: package "main" (isInitialPkg: true,...

I think that bodyclose produces false positive warning on this code: response body is closed in a separate function inside each logic case. I can not use defer response.Body.Close() due...

revive is so hot now https://github.com/mgechev/revive what about beinig a part of it?

### summary Similar to #18, when the `http.Response.Body.Close` method is extracted and called, `bodyclose` misses the call and incorrectly warns: ```go resp, err := http.Get("http://example.com/") if err != nil {...

The following code is fine, because it closes the body only when the error is `nil`, but gets `response body must be closed` errors on both the `d.client.Do(req)` lines. ```go...

This program ``` package main import ( "net/http" ) func main() { var resp *http.Response var fizz bool if fizz { resp, _ = foo() } else { resp, _...