Skip to content

Commit

Permalink
bugfix: adjust or add close request body.
Browse files Browse the repository at this point in the history
affected modules:
- lease/leasehttp
- contrib/raftexample
  • Loading branch information
johncming committed Mar 12, 2019
1 parent 6da17cd commit e46af03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/raftexample/httpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type httpKVAPI struct {

func (h *httpKVAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
key := r.RequestURI
defer r.Body.Close()
switch {
case r.Method == "PUT":
v, err := ioutil.ReadAll(r.Body)
Expand Down
1 change: 1 addition & 0 deletions lease/leasehttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "error reading body", http.StatusBadRequest)
Expand Down

0 comments on commit e46af03

Please sign in to comment.