Skip to content

Commit 823004f

Browse files
author
Dean Karn
authored
fix closing of body prematurely (#32)
1 parent 6148921 commit 823004f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [5.17.2] - 2023-05-09
10+
### Fixed
11+
- Prematurely closing http.Response Body before error with it can be intercepted for ErrUnexpectedResponse.
12+
913
## [5.17.1] - 2023-05-09
1014
### Fixed
1115
- ErrRetryableStatusCode passing the *http.Response to have access to not only the status code but headers etc. related to retrying.
@@ -42,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4246
### Added
4347
- Added `timext.NanoTime` for fast low level monotonic time with nanosecond precision.
4448

45-
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.17.1...HEAD
49+
[Unreleased]: https://github.com/go-playground/pkg/compare/v5.17.2...HEAD
50+
[5.17.2]: https://github.com/go-playground/pkg/compare/v5.17.1..v5.17.2
4651
[5.17.1]: https://github.com/go-playground/pkg/compare/v5.17.0...v5.17.1
4752
[5.17.0]: https://github.com/go-playground/pkg/compare/v5.16.0...v5.17.0
4853
[5.16.0]: https://github.com/go-playground/pkg/compare/v5.15.2...v5.16.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pkg
22

3-
![Project status](https://img.shields.io/badge/version-5.17.1-green.svg)
3+
![Project status](https://img.shields.io/badge/version-5.17.2-green.svg)
44
[![Lint & Test](https://github.com/go-playground/pkg/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/pkg/actions/workflows/go.yml)
55
[![Coverage Status](https://coveralls.io/repos/github/go-playground/pkg/badge.svg?branch=master)](https://coveralls.io/github/go-playground/pkg?branch=master)
66
[![GoDoc](https://godoc.org/github.com/go-playground/pkg?status.svg)](https://pkg.go.dev/mod/github.com/go-playground/pkg/v5)

net/http/retryable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ func DoRetryable[T any](ctx context.Context, isRetryableFn errorsext.IsRetryable
110110
return resultext.Err[T, error](result.Err())
111111
}
112112
resp := result.Unwrap()
113-
defer resp.Body.Close()
114113

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

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

0 commit comments

Comments
 (0)