mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
feat: drains http body if buffer is too small
Signed-off-by: divinerapier <poriter.coco@gmail.com>
This commit is contained in:
parent
84640d07b7
commit
4cbb6fa199
|
@ -235,8 +235,16 @@ func ReadUrl(fileUrl string, offset int64, size int, buf []byte, isReadRange boo
|
|||
if err != nil {
|
||||
return n, err
|
||||
}
|
||||
if n == int64(len(buf)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// drains the response body to avoid memory leak
|
||||
data, err := ioutil.ReadAll(reader)
|
||||
if len(data) != 0 {
|
||||
err = fmt.Errorf("buffer size is too small. remains %d", len(data))
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func ReadUrlAsStream(fileUrl string, offset int64, size int, fn func(data []byte)) (int64, error) {
|
||||
|
|
Loading…
Reference in a new issue