close + drain body if response body is too large (#2897)

This commit is contained in:
kim 2024-05-05 15:43:38 +00:00 committed by GitHub
parent 6171dcbe51
commit d3f6960ba0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -400,6 +400,7 @@ func (c *Client) do(r *Request) (rsp *http.Response, retry bool, err error) {
// Check response body not too large. // Check response body not too large.
if rsp.ContentLength > c.bodyMax { if rsp.ContentLength > c.bodyMax {
_ = rsp.Body.Close()
return nil, false, ErrBodyTooLarge return nil, false, ErrBodyTooLarge
} }