[lbry] rpcclient: fix http response resource leaking

This commit is contained in:
Roy Lee 2022-05-24 00:00:31 -07:00
parent fb3ef35189
commit 096dd3ff75

View file

@ -803,6 +803,7 @@ func (c *Client) handleSendPostMessage(jReq *jsonRequest) {
time.Sleep(backoff)
continue
}
defer httpResponse.Body.Close()
break
}
if err != nil {
@ -810,9 +811,8 @@ func (c *Client) handleSendPostMessage(jReq *jsonRequest) {
return
}
// Read the raw bytes and close the response.
// Read the raw bytes from the response.
respBytes, err := ioutil.ReadAll(httpResponse.Body)
httpResponse.Body.Close()
if err != nil {
err = fmt.Errorf("error reading json reply: %v", err)
jReq.responseChan <- &Response{err: err}
@ -1386,6 +1386,7 @@ func dial(config *ConnConfig) (*websocket.Conn, error) {
// cases above apply.
return nil, errors.New(resp.Status)
}
resp.Body.Close()
return wsConn, nil
}