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 592fba2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/clients/base/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package base
import (
"context"
"fmt"
"github.com/rudderlabs/rudder-go-kit/httputil"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -36,7 +37,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 592fba2

Please sign in to comment.