diff --git a/api/internal/bus/client.go b/api/internal/bus/client.go index 9ac6d47..a0fb1e4 100644 --- a/api/internal/bus/client.go +++ b/api/internal/bus/client.go @@ -61,6 +61,7 @@ func (c *Client) makeRequest(url, method string, body []byte) ([]byte, error) { if err != nil { return nil, fmt.Errorf("request failed: %s", err) } + defer response.Body.Close() responseBody, err := ioutil.ReadAll(response.Body) if err != nil { diff --git a/api/internal/bus/connect.go b/api/internal/bus/connect.go index 1e02697..78e106f 100644 --- a/api/internal/bus/connect.go +++ b/api/internal/bus/connect.go @@ -56,6 +56,7 @@ func openSession(url string, body io.Reader, httpClient *http.Client) (sessionID if err != nil { return "", err } + defer response.Body.Close() var sessionResponse struct{ SessionID string } responseBody, err := ioutil.ReadAll(response.Body) diff --git a/api/internal/service/service.go b/api/internal/service/service.go index 93972a3..cf25daf 100644 --- a/api/internal/service/service.go +++ b/api/internal/service/service.go @@ -135,7 +135,11 @@ func (s *Service) checkStatus() bool { client := &http.Client{} request, _ := http.NewRequest("GET", fmt.Sprintf("%s/status", s.url), nil) response, err := client.Do(request) - if err == nil && response.StatusCode == 200 { + if err != nil { + return false + } + defer response.Body.Close() + if response.StatusCode == 200 { return true } return false