bugfix: adjust or add close request body.
affected modules: - lease/leasehttp - contrib/raftexamplerelease-3.4
parent
6da17cda18
commit
e46af034df
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue