Skip to content

Commit dc50416

Browse files
authored
Merge pull request #10534 from johncming/close_reader
close http request body after read it.
2 parents b7ad8c6 + e46af03 commit dc50416

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)