Skip to content

Commit

Permalink
return err if new request's error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
chengshiwen committed Aug 15, 2024
1 parent fb80288 commit e98d34c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (hb *HttpBackend) WriteStream(org, bucket string, stream io.Reader, compres
req, err := http.NewRequest("POST", hb.Url+"/api/v2/write?"+q.Encode(), stream)
if err != nil {
log.Print("new request error: ", err)
return nil
return err
}
hb.SetAuthorization(req)
if compressed {
Expand Down Expand Up @@ -307,7 +307,7 @@ func (hb *HttpBackend) Query(req *http.Request, w http.ResponseWriter, decompres
CopyHeader(w.Header(), resp.Header)
}

respBody := resp.Body
body := resp.Body
if decompress && resp.Header.Get("Content-Encoding") == "gzip" {
b, err := gzip.NewReader(resp.Body)
if err != nil {
Expand All @@ -316,10 +316,10 @@ func (hb *HttpBackend) Query(req *http.Request, w http.ResponseWriter, decompres
return
}
defer b.Close()
respBody = b
body = b
}

qr.Body, qr.Err = io.ReadAll(respBody)
qr.Body, qr.Err = io.ReadAll(body)
if qr.Err != nil {
log.Printf("read body error: %s, the query is %s", qr.Err, q)
return
Expand Down

0 comments on commit e98d34c

Please sign in to comment.