close + drain body if response body is too large (#2897)
This commit is contained in:
parent
6171dcbe51
commit
d3f6960ba0
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue