mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #10534 from johncming/close_reader
close http request body after read it.
This commit is contained in:
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…
x
Reference in New Issue
Block a user