aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-08 18:07:07 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-08 18:07:07 -0800
commit89e16bd2e8edabee4d5b09c29dcc31ae023dc18d (patch)
treefb5ca50d6ad4fa3bb95c567005959a3af2285ccd
parent66ab09aa4aec71fb4fc1abb64e1eea15a7cb4320 (diff)
downloadseaweedfs-89e16bd2e8edabee4d5b09c29dcc31ae023dc18d.tar.xz
seaweedfs-89e16bd2e8edabee4d5b09c29dcc31ae023dc18d.zip
skip error when draining reader
fix https://github.com/chrislusf/seaweedfs/issues/1179
-rw-r--r--weed/util/http_util.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/weed/util/http_util.go b/weed/util/http_util.go
index 667d0b4be..4aab90f5a 100644
--- a/weed/util/http_util.go
+++ b/weed/util/http_util.go
@@ -11,6 +11,8 @@ import (
"net/http"
"net/url"
"strings"
+
+ "github.com/chrislusf/seaweedfs/weed/glog"
)
var (
@@ -210,7 +212,8 @@ func ReadUrl(fileUrl string, offset int64, size int, buf []byte, isReadRange boo
}
var reader io.ReadCloser
- switch r.Header.Get("Content-Encoding") {
+ contentEncoding := r.Header.Get("Content-Encoding")
+ switch contentEncoding {
case "gzip":
reader, err = gzip.NewReader(r.Body)
defer reader.Close()
@@ -242,7 +245,7 @@ func ReadUrl(fileUrl string, offset int64, size int, buf []byte, isReadRange boo
// drains the response body to avoid memory leak
data, _ := ioutil.ReadAll(reader)
if len(data) != 0 {
- err = fmt.Errorf("buffer size is too small. remains %d", len(data))
+ glog.V(1).Infof("%s reader has remaining %d bytes", contentEncoding, len(data))
}
return n, err
}