mirror of
https://github.com/mailgun/groupcache.git
synced 2024-07-01 02:19:12 +00:00
Add HTTP error message from peer to error returned from httpGetter.Get
This commit is contained in:
parent
4707649ec3
commit
131b5ec788
3
http.go
3
http.go
|
@ -299,7 +299,8 @@ func (h *httpGetter) Get(ctx context.Context, in *pb.GetRequest, out *pb.GetResp
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
return fmt.Errorf("server returned: %v", res.Status)
|
msg, _ := ioutil.ReadAll(io.LimitReader(res.Body, 10*1024*1024)) // Limit reading the error body to max 10 MiB
|
||||||
|
return fmt.Errorf("server returned: %v, %v", res.Status, msg)
|
||||||
}
|
}
|
||||||
b := bufferPool.Get().(*bytes.Buffer)
|
b := bufferPool.Get().(*bytes.Buffer)
|
||||||
b.Reset()
|
b.Reset()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user