mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Make sure to drain body upon an error (#7197)
Also cleanup redundant code and use it at a common place
This commit is contained in:
committed by
kannappanr
parent
2d168b532b
commit
817269475f
@@ -59,9 +59,9 @@ func (c *Client) Call(method string, values url.Values, body io.Reader, length i
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
defer xhttp.DrainBody(resp.Body)
|
||||
// Limit the ReadAll(), just in case, because of a bug, the server responds with large data.
|
||||
r := io.LimitReader(resp.Body, 1024)
|
||||
b, err := ioutil.ReadAll(r)
|
||||
b, err := ioutil.ReadAll(io.LimitReader(resp.Body, 4096))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user