Merge pull request #10534 from johncming/close_reader

close http request body after read it.
release-3.4
Xiang Li 2019-03-12 08:25:32 -07:00 committed by GitHub
commit dc50416157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -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)

View File

@ -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)