aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorGravatar Max Denushev <mdenushev@ya.ru> 2024-04-22 11:45:33 +0500
committerGravatar GitHub <noreply@github.com> 2024-04-22 08:45:33 +0200
commit57b9352ad1cc93a0aaaa72b2130e03ace8a5b118 (patch)
tree2d70338e58a3243d05709b1fcd660cccc1ddcb94 /client.go
parentrefactor: do not return error as it is always nil (#1759) (diff)
downloadfasthttp-57b9352ad1cc93a0aaaa72b2130e03ace8a5b118.tar.gz
fasthttp-57b9352ad1cc93a0aaaa72b2130e03ace8a5b118.tar.bz2
fasthttp-57b9352ad1cc93a0aaaa72b2130e03ace8a5b118.zip
fix: propagate body stream error to close function (#1743) (#1757)
* fix: propagate body stream error to close function (#1743) * fix: http test * fix: close body stream with error in encoding functions * fix: lint --------- Co-authored-by: Max Denushev <denushev@tochka.com>
Diffstat (limited to 'client.go')
-rw-r--r--client.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/client.go b/client.go
index b5493e9..1f12d4a 100644
--- a/client.go
+++ b/client.go
@@ -2975,12 +2975,12 @@ func (t *transport) RoundTrip(hc *HostClient, req *Request, resp *Response) (ret
closeConn := resetConnection || req.ConnectionClose() || resp.ConnectionClose() || isConnRST
if customStreamBody && resp.bodyStream != nil {
rbs := resp.bodyStream
- resp.bodyStream = newCloseReader(rbs, func() error {
+ resp.bodyStream = newCloseReaderWithError(rbs, func(wErr error) error {
hc.releaseReader(br)
if r, ok := rbs.(*requestStream); ok {
releaseRequestStream(r)
}
- if closeConn || resp.ConnectionClose() {
+ if closeConn || resp.ConnectionClose() || wErr != nil {
hc.closeConn(cc)
} else {
hc.releaseConn(cc)