Skip to content

Commit

Permalink
fix: response body after HTTP error should be closed (#106)
Browse files Browse the repository at this point in the history
* fix: (WIP) #102 close response body on error

* test: adds basic test of close resp body

* chore: fix linter issue

* test: adds integration test of resp.Body.Close() on error

* docs: update CHANGELOG.md

* docs: update CHANGELOG.md

* chore: refactor location of resp.Body.Close()

* chore: remove unnecessary tests
  • Loading branch information
karel-rehor authored Sep 27, 2024
1 parent 68a0862 commit 5671330
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## 0.11.0 [unreleased]

### Bug Fixes

1. [#105](https://github.com/InfluxCommunity/influxdb3-go/pull/105): Support newlines in tag values.
1. [#106](https://github.com/InfluxCommunity/influxdb3-go/pull/106): Close `resp.Body` after HTTP error response is encountered.

## 0.10.0 [2024-09-13]

Expand Down
4 changes: 3 additions & 1 deletion influxdb3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func (c *Client) makeAPICall(ctx context.Context, params httpParams) (*http.Resp
if err != nil {
return nil, err
}

return resp, nil
}

Expand All @@ -199,6 +198,9 @@ func (c *Client) resolveHTTPError(r *http.Response) error {
if r.StatusCode >= 200 && r.StatusCode < 300 {
return nil
}
defer func() {
_ = r.Body.Close()
}()

var httpError struct {
ServerError
Expand Down

0 comments on commit 5671330

Please sign in to comment.