Skip to content

Commit e46af03

Browse files
committed
bugfix: adjust or add close request body.
affected modules: - lease/leasehttp - contrib/raftexample
1 parent 6da17cd commit e46af03

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Diff for: contrib/raftexample/httpapi.go

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type httpKVAPI struct {
3131

3232
func (h *httpKVAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
3333
key := r.RequestURI
34+
defer r.Body.Close()
3435
switch {
3536
case r.Method == "PUT":
3637
v, err := ioutil.ReadAll(r.Body)

Diff for: lease/leasehttp/http.go

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
5252
return
5353
}
5454

55+
defer r.Body.Close()
5556
b, err := ioutil.ReadAll(r.Body)
5657
if err != nil {
5758
http.Error(w, "error reading body", http.StatusBadRequest)

0 commit comments

Comments
 (0)