Skip to content

Commit

Permalink
chore: close response if response code is different
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Feb 8, 2024
1 parent c19d7c4 commit 6ca9652
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/clients/base/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"io"
"net/http"
"net/url"

"github.com/rudderlabs/rudder-go-kit/httputil"
)

type Client struct {
Expand Down Expand Up @@ -36,7 +38,9 @@ func (c *Client) Send(req *http.Request) ([]byte, error) {
if err != nil {
return nil, err
}
defer res.Body.Close()
defer func() {
httputil.CloseResponse(res)
}()

if res.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %d", res.StatusCode)
Expand Down

0 comments on commit 6ca9652

Please sign in to comment.