Skip to content

Commit

Permalink
Remove() Now returns the body on non 200 response
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed May 23, 2019
1 parent 2ce33c3 commit 2e501aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion groupcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (g *Group) Remove(ctx Context, key string) error {
return nil, err
}
}
// Remove from our cache first in case we are owner
// Remove from our cache next
g.localRemove(key)
wg := sync.WaitGroup{}
errs := make(chan error)
Expand Down
10 changes: 8 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -273,9 +274,14 @@ func (h *httpGetter) Remove(ctx Context, in *pb.GetRequest) error {
if err := h.makeRequest(ctx, http.MethodDelete, in, &res); err != nil {
return err
}
res.Body.Close()
defer res.Body.Close()

if res.StatusCode != http.StatusOK {
return fmt.Errorf("server returned: %v", res.Status)
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("while reading body response: %v", res.Status)
}
return fmt.Errorf("server returned status %d: %s", res.StatusCode, body)
}
return nil
}

0 comments on commit 2e501aa

Please sign in to comment.