Merge pull request #10534 from johncming/close_reader
close http request body after read it.release-3.4
commit
dc50416157
|
@ -31,6 +31,7 @@ type httpKVAPI struct {
|
||||||
|
|
||||||
func (h *httpKVAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *httpKVAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
key := r.RequestURI
|
key := r.RequestURI
|
||||||
|
defer r.Body.Close()
|
||||||
switch {
|
switch {
|
||||||
case r.Method == "PUT":
|
case r.Method == "PUT":
|
||||||
v, err := ioutil.ReadAll(r.Body)
|
v, err := ioutil.ReadAll(r.Body)
|
||||||
|
|
|
@ -52,6 +52,7 @@ func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer r.Body.Close()
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := ioutil.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "error reading body", http.StatusBadRequest)
|
http.Error(w, "error reading body", http.StatusBadRequest)
|
||||||
|
|
Loading…
Reference in New Issue