Browse Source

weed/util: fix dropped errors (#4803)

pull/4805/head
Lars Lehtonen 1 year ago
committed by GitHub
parent
commit
e6385e5e8b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      weed/util/http_util.go

12
weed/util/http_util.go

@ -54,6 +54,9 @@ func Post(url string, values url.Values) ([]byte, error) {
func Get(url string) ([]byte, bool, error) { func Get(url string) ([]byte, bool, error) {
request, err := http.NewRequest("GET", url, nil) request, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, true, err
}
request.Header.Add("Accept-Encoding", "gzip") request.Header.Add("Accept-Encoding", "gzip")
response, err := client.Do(request) response, err := client.Do(request)
@ -66,6 +69,9 @@ func Get(url string) ([]byte, bool, error) {
switch response.Header.Get("Content-Encoding") { switch response.Header.Get("Content-Encoding") {
case "gzip": case "gzip":
reader, err = gzip.NewReader(response.Body) reader, err = gzip.NewReader(response.Body)
if err != nil {
return nil, true, err
}
defer reader.Close() defer reader.Close()
default: default:
reader = response.Body reader = response.Body
@ -253,6 +259,9 @@ func ReadUrl(fileUrl string, cipherKey []byte, isContentCompressed bool, isFullC
switch contentEncoding { switch contentEncoding {
case "gzip": case "gzip":
reader, err = gzip.NewReader(r.Body) reader, err = gzip.NewReader(r.Body)
if err != nil {
return 0, err
}
defer reader.Close() defer reader.Close()
default: default:
reader = r.Body reader = r.Body
@ -400,6 +409,9 @@ func ReadUrlAsReaderCloser(fileUrl string, jwt string, rangeHeader string) (*htt
switch contentEncoding { switch contentEncoding {
case "gzip": case "gzip":
reader, err = gzip.NewReader(r.Body) reader, err = gzip.NewReader(r.Body)
if err != nil {
return nil, nil, err
}
default: default:
reader = r.Body reader = r.Body
} }

Loading…
Cancel
Save