Просмотр исходного кода

etcdserver/api/rafthttp: fix the location of close http body.

johncming 6 лет назад
Родитель
Сommit
bd41f74168
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      etcdserver/api/rafthttp/pipeline.go

+ 1 - 1
etcdserver/api/rafthttp/pipeline.go

@@ -155,12 +155,12 @@ func (p *pipeline) post(data []byte) (err error) {
 		p.picker.unreachable(u)
 		return err
 	}
+	defer resp.Body.Close()
 	b, err := ioutil.ReadAll(resp.Body)
 	if err != nil {
 		p.picker.unreachable(u)
 		return err
 	}
-	resp.Body.Close()
 
 	err = checkPostResponse(resp, b, req, p.peerID)
 	if err != nil {