@@ -470,6 +470,7 @@ func getAPIVersions(httpClient *http.Client, endpoint string) (*versions, error)
470470 if err != nil {
471471 return nil , fmt .Errorf ("%v is not accessible: %w" , endpoint , err )
472472 }
473+ defer resp .Body .Close ()
473474
474475 if resp .StatusCode != http .StatusOK {
475476 return nil , fmt .Errorf ("%v is not accessible: expected %v response, got %v" , endpoint , http .StatusOK , resp .StatusCode )
@@ -732,6 +733,7 @@ func (client *NginxClient) get(path string, data interface{}) error {
732733 "expected %v response, got %v" ,
733734 http .StatusOK , resp .StatusCode ))
734735 }
736+ defer resp .Body .Close ()
735737
736738 body , err := ioutil .ReadAll (resp .Body )
737739 if err != nil {
@@ -766,6 +768,8 @@ func (client *NginxClient) post(path string, input interface{}) error {
766768 if err != nil {
767769 return fmt .Errorf ("failed to post %v: %w" , path , err )
768770 }
771+ defer resp .Body .Close ()
772+
769773 if resp .StatusCode != http .StatusCreated {
770774 return createResponseMismatchError (resp .Body ).Wrap (fmt .Sprintf (
771775 "expected %v response, got %v" ,
@@ -790,6 +794,8 @@ func (client *NginxClient) delete(path string, expectedStatusCode int) error {
790794 if err != nil {
791795 return fmt .Errorf ("failed to create delete request: %w" , err )
792796 }
797+ defer resp .Body .Close ()
798+
793799 if resp .StatusCode != expectedStatusCode {
794800 return createResponseMismatchError (resp .Body ).Wrap (fmt .Sprintf (
795801 "failed to complete delete request: expected %v response, got %v" ,
0 commit comments