diff --git a/client.go b/client.go index 8476b99c..dc2f5783 100644 --- a/client.go +++ b/client.go @@ -179,15 +179,15 @@ func (c *APIClient) Patch(url string, payload interface{}) (*http.Response, erro } // Delete performs a Delete request against the Redfish service. -func (c *APIClient) Delete(url string) error { +func (c *APIClient) Delete(url string) (*http.Response, error) { resp, err := c.runRequest(http.MethodDelete, url, nil) if err != nil { - return err + return nil, err } if resp != nil && resp.Body != nil { resp.Body.Close() } - return nil + return resp, nil } // runRequest actually performs the REST calls. diff --git a/common/testclient.go b/common/testclient.go index cdb4b240..46b2fa6d 100644 --- a/common/testclient.go +++ b/common/testclient.go @@ -155,11 +155,11 @@ func (c *TestClient) Patch(url string, payload interface{}) (*http.Response, err } // Delete performs a Delete request against the Redfish service. -func (c *TestClient) Delete(url string) error { +func (c *TestClient) Delete(url string) (*http.Response, error) { c.recordCall(http.MethodDelete, url, nil) customReturnForAction := c.getCustomReturnForAction(http.MethodDelete) if customReturnForAction == nil { - return nil + return nil, nil } - return customReturnForAction.(error) + return customReturnForAction.(*http.Response), nil } diff --git a/common/types.go b/common/types.go index 5fe7d61d..f102ece3 100644 --- a/common/types.go +++ b/common/types.go @@ -20,7 +20,7 @@ type Client interface { Post(url string, payload interface{}) (*http.Response, error) Patch(url string, payload interface{}) (*http.Response, error) Put(url string, payload interface{}) (*http.Response, error) - Delete(url string) error + Delete(url string) (*http.Response, error) } // Entity provides the common basis for all Redfish and Swordfish objects. diff --git a/redfish/eventdestination.go b/redfish/eventdestination.go index 39909cc7..8f03abab 100644 --- a/redfish/eventdestination.go +++ b/redfish/eventdestination.go @@ -389,8 +389,10 @@ func DeleteEventDestination(c common.Client, uri string) (err error) { if len(strings.TrimSpace(uri)) == 0 { return fmt.Errorf("uri should not be empty") } + _, err = c.Delete(uri) + //defer resp.Body.Close() - return c.Delete(uri) + return err } // ListReferencedEventDestinations gets the collection of EventDestination from diff --git a/redfish/session.go b/redfish/session.go index 446cc89a..130b4e3a 100644 --- a/redfish/session.go +++ b/redfish/session.go @@ -104,7 +104,12 @@ func CreateSession(c common.Client, uri string, username string, password string // DeleteSession deletes a session using the location as argument func DeleteSession(c common.Client, url string) (err error) { - return c.Delete(url) + resp, err := c.Delete(url) + if err != nil { + return err + } + defer resp.Body.Close() + return nil } // GetSession will get a Session instance from the Redfish service.