close + drain body if response body is too large

This commit is contained in:
kim 2024-05-05 13:54:04 +01:00
parent 6171dcbe51
commit 207c65f321
1 changed files with 1 additions and 0 deletions

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.
if rsp.ContentLength > c.bodyMax {
_ = rsp.Body.Close()
return nil, false, ErrBodyTooLarge
}