Skip to content

response body must be closed (bodyclose) when net/http is imported #121

Answered by earthboundkid
Crocmagnon asked this question in Bugs
Discussion options

You must be logged in to vote

This is almost certainly a false positive. All request-responses go through the do function, which ensures Body.Close is called.

func do(cl *http.Client, req *http.Request, validators []ResponseHandler, h ResponseHandler) (doResponse, error) {
        res, err := cl.Do(req)
        if err != nil {
                return doConnect, err
        }
        defer res.Body.Close()


        for _, v := range validators {
                if v == nil {
                        continue
                }
                if err = v(res); err != nil {
                        return doValidate, err
                }
        }
        if err = h(res); err != nil {
                return doHandle, err

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@Crocmagnon
Comment options

@Crocmagnon
Comment options

Answer selected by Crocmagnon
Comment options

You must be logged in to vote
1 reply
@earthboundkid
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Bugs
Labels
None yet
3 participants