http exhaust and close response body

This commit is contained in:
Chris Lu
2019-04-14 23:28:24 -07:00
parent 3e8a3a8fec
commit e85048bcdc
3 changed files with 15 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"google.golang.org/grpc"
"io"
"io/ioutil"
"net/http"
"sort"
@@ -103,7 +104,10 @@ func readChunkNeedle(fileUrl string, w io.Writer, offset int64) (written int64,
if err != nil {
return written, err
}
defer resp.Body.Close()
defer func() {
io.Copy(ioutil.Discard, resp.Body)
resp.Body.Close()
}()
switch resp.StatusCode {
case http.StatusRequestedRangeNotSatisfiable: