Skip to content

Commit

Permalink
fix closing of body prematurely (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Karn authored May 9, 2023
1 parent 6148921 commit 823004f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.17.2] - 2023-05-09
### Fixed
- Prematurely closing http.Response Body before error with it can be intercepted for ErrUnexpectedResponse.

## [5.17.1] - 2023-05-09
### Fixed
- ErrRetryableStatusCode passing the *http.Response to have access to not only the status code but headers etc. related to retrying.
Expand Down Expand Up @@ -42,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added `timext.NanoTime` for fast low level monotonic time with nanosecond precision.

[Unreleased]: https://github.com/go-playground/pkg/compare/v5.17.1...HEAD
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.17.2...HEAD
[5.17.2]: https://github.com/go-playground/pkg/compare/v5.17.1..v5.17.2
[5.17.1]: https://github.com/go-playground/pkg/compare/v5.17.0...v5.17.1
[5.17.0]: https://github.com/go-playground/pkg/compare/v5.16.0...v5.17.0
[5.16.0]: https://github.com/go-playground/pkg/compare/v5.15.2...v5.16.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pkg

![Project status](https://img.shields.io/badge/version-5.17.1-green.svg)
![Project status](https://img.shields.io/badge/version-5.17.2-green.svg)
[![Lint & Test](https://github.com/go-playground/pkg/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/pkg/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pkg/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pkg?branch=master)
[![GoDoc](https://godoc.org/github.com/go-playground/pkg?status.svg)](https://pkg.go.dev/mod/github.com/go-playground/pkg/v5)
Expand Down
2 changes: 1 addition & 1 deletion net/http/retryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func DoRetryable[T any](ctx context.Context, isRetryableFn errorsext.IsRetryable
return resultext.Err[T, error](result.Err())
}
resp := result.Unwrap()
defer resp.Body.Close()

if resp.StatusCode != expectedResponseCode {
return resultext.Err[T, error](ErrUnexpectedResponse{Response: resp})
}
defer resp.Body.Close()

data, err := DecodeResponse[T](resp, maxMemory)
if err != nil {
Expand Down

0 comments on commit 823004f

Please sign in to comment.