Merge pull request #1297 from cthach/fix-nest-extend-stream

fix(nest): Resource leak due to lack of closing HTTP response bodies
This commit is contained in:
Alex X
2024-08-07 16:38:38 +03:00
committed by GitHub
+5
View File
@@ -53,6 +53,8 @@ func NewAPI(clientID, clientSecret, refreshToken string) (*API, error) {
if err != nil {
return nil, err
}
defer res.Body.Close()
if res.StatusCode != 200 {
return nil, errors.New("nest: wrong status: " + res.Status)
}
@@ -92,6 +94,7 @@ func (a *API) GetDevices(projectID string) (map[string]string, error) {
if err != nil {
return nil, err
}
defer res.Body.Close()
if res.StatusCode != 200 {
return nil, errors.New("nest: wrong status: " + res.Status)
@@ -157,6 +160,7 @@ func (a *API) ExchangeSDP(projectID, deviceID, offer string) (string, error) {
if err != nil {
return "", err
}
defer res.Body.Close()
if res.StatusCode != 200 {
return "", errors.New("nest: wrong status: " + res.Status)
@@ -211,6 +215,7 @@ func (a *API) ExtendStream() error {
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != 200 {
return errors.New("nest: wrong status: " + res.Status)