Closed OwenLIULIU closed 6 years ago
resp, err := grequests.Post(url, options)
if err != nil {
//
}
if resp.StatusCode != 200 {
// resp.RawResponse.Body.Close() or resp.String()
}
You need to close the resp
if you use it.
@levigross In my case, I don't care about the content of resp
, what I want is just check error or not 200
, in other word, the request fails.
Then do I still have to close the resp
manually either?
Yes
above is my code, and after about 2 weeks, I could get an error as
socket: too many open files
. I don't know whether it due to the response unclosed.resp
only used to get StatusCode, noresp.JSON
or any other usages.Should i must close the connection? like defer resp.Close(). Or what should I do to avoid this socket error?