diff --git a/contrib/raftexample/httpapi.go b/contrib/raftexample/httpapi.go index 86d27d397..75f5d616f 100644 --- a/contrib/raftexample/httpapi.go +++ b/contrib/raftexample/httpapi.go @@ -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) diff --git a/lease/leasehttp/http.go b/lease/leasehttp/http.go index 0f9c0c865..67e916dba 100644 --- a/lease/leasehttp/http.go +++ b/lease/leasehttp/http.go @@ -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)