Close body on fail

This commit is contained in:
Fangliding
2026-05-08 13:39:42 +08:00
parent 228f1e13aa
commit 1bae46b1c0

View File

@@ -71,6 +71,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
errors.LogInfoInner(ctx, err, "failed to "+method+" "+url)
}
gotConn.Close()
common.Close(body)
wrc.Close()
return
}
@@ -80,6 +81,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
if resp.StatusCode != 200 || uploadOnly { // stream-up
io.Copy(io.Discard, resp.Body)
resp.Body.Close() // if it is called immediately, the upload will be interrupted also
common.Close(body)
wrc.Close()
return
}