should not close request body

pull/820/head
Xiang Li 2013-08-02 07:59:16 -07:00
parent 403140b49a
commit 8865839357
2 changed files with 2 additions and 3 deletions

View File

@ -161,7 +161,6 @@ func (t *HTTPTransporter) appendEntriesHandler(server *Server) http.HandlerFunc
return func(w http.ResponseWriter, r *http.Request) {
traceln(server.Name(), "RECV /appendEntries")
defer r.Body.Close()
req := &AppendEntriesRequest{}
if _, err := req.decode(r.Body); err != nil {
http.Error(w, "", http.StatusBadRequest)
@ -181,7 +180,6 @@ func (t *HTTPTransporter) requestVoteHandler(server *Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
traceln(server.Name(), "RECV /requestVote")
defer r.Body.Close()
req := &RequestVoteRequest{}
if _, err := req.decode(r.Body); err != nil {
http.Error(w, "", http.StatusBadRequest)

View File

@ -388,7 +388,8 @@ func TestServerMultiNode(t *testing.T) {
var leader *Server
for _, name := range names {
server := newTestServer(name, transporter)
defer server.Stop()
mutex.Lock()
servers[name] = server
mutex.Unlock()