This PR removes if resp != nil check when creating a session in proxy.go.
The resp object cannot be nil in this code, as it is assigned the return value of httpClient.Do(req) method call, which returns a non-nil response object or an `error if the request could not be sent or the server returns an error response. From the documentation:
If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close.
...
The request Body, if non-nil, will be closed by the underlying Transport, even on errors.
Actually, the code has leaked resources, but in proxy_test.go. Every call to http.Get must be accompanied by rsp.Body.Close() call. These places can be found by bodyclose linter.
This PR removes
if resp != nil
check when creating a session inproxy.go
.The
resp
object cannot benil
in this code, as it is assigned the return value ofhttpClient.Do(req)
method call, which returns a non-nil response object or an `error if the request could not be sent or the server returns an error response. From the documentation:Actually, the code has leaked resources, but in
proxy_test.go
. Every call tohttp.Get
must be accompanied byrsp.Body.Close()
call. These places can be found by bodyclose linter.