@@ -470,6 +470,7 @@ func getAPIVersions(httpClient *http.Client, endpoint string) (*versions, error)
470
470
if err != nil {
471
471
return nil , fmt .Errorf ("%v is not accessible: %w" , endpoint , err )
472
472
}
473
+ defer resp .Body .Close ()
473
474
474
475
if resp .StatusCode != http .StatusOK {
475
476
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 {
732
733
"expected %v response, got %v" ,
733
734
http .StatusOK , resp .StatusCode ))
734
735
}
736
+ defer resp .Body .Close ()
735
737
736
738
body , err := ioutil .ReadAll (resp .Body )
737
739
if err != nil {
@@ -766,6 +768,8 @@ func (client *NginxClient) post(path string, input interface{}) error {
766
768
if err != nil {
767
769
return fmt .Errorf ("failed to post %v: %w" , path , err )
768
770
}
771
+ defer resp .Body .Close ()
772
+
769
773
if resp .StatusCode != http .StatusCreated {
770
774
return createResponseMismatchError (resp .Body ).Wrap (fmt .Sprintf (
771
775
"expected %v response, got %v" ,
@@ -790,6 +794,8 @@ func (client *NginxClient) delete(path string, expectedStatusCode int) error {
790
794
if err != nil {
791
795
return fmt .Errorf ("failed to create delete request: %w" , err )
792
796
}
797
+ defer resp .Body .Close ()
798
+
793
799
if resp .StatusCode != expectedStatusCode {
794
800
return createResponseMismatchError (resp .Body ).Wrap (fmt .Sprintf (
795
801
"failed to complete delete request: expected %v response, got %v" ,
0 commit comments