mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdhttp: check error returned by ParseForm
This commit is contained in:
parent
99e35554c0
commit
6d0658c8ca
@ -135,7 +135,10 @@ func (h serverHandler) serveAdminMembers(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
switch r.Method {
|
||||
case "PUT":
|
||||
r.ParseForm()
|
||||
if err := r.ParseForm(); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
peerURLs := r.PostForm["PeerURLs"]
|
||||
log.Printf("etcdhttp: add node %x with peer urls %v", id, peerURLs)
|
||||
m := etcdserver.Member{
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
@ -1277,11 +1278,22 @@ func TestServeAdminMembersFail(t *testing.T) {
|
||||
|
||||
http.StatusBadRequest,
|
||||
},
|
||||
{
|
||||
// parse body error
|
||||
&http.Request{
|
||||
URL: mustNewURL(t, path.Join(adminMembersPrefix, "1")),
|
||||
Method: "PUT",
|
||||
},
|
||||
&resServer{},
|
||||
|
||||
http.StatusBadRequest,
|
||||
},
|
||||
{
|
||||
// etcdserver.AddMember error
|
||||
&http.Request{
|
||||
URL: mustNewURL(t, path.Join(adminMembersPrefix, "1")),
|
||||
Method: "PUT",
|
||||
Body: ioutil.NopCloser(strings.NewReader("")),
|
||||
},
|
||||
&errServer{
|
||||
errors.New("blah"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user