mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdhttp: parse quorum field from http request
This commit is contained in:
parent
4c9d67aaa2
commit
0e1d1646fd
@ -358,7 +358,7 @@ func parseKeyRequest(r *http.Request, id uint64, clock clockwork.Clock) (etcdser
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var rec, sort, wait, dir, stream bool
|
var rec, sort, wait, dir, quorum, stream bool
|
||||||
if rec, err = getBool(r.Form, "recursive"); err != nil {
|
if rec, err = getBool(r.Form, "recursive"); err != nil {
|
||||||
return emptyReq, etcdErr.NewRequestError(
|
return emptyReq, etcdErr.NewRequestError(
|
||||||
etcdErr.EcodeInvalidField,
|
etcdErr.EcodeInvalidField,
|
||||||
@ -384,6 +384,12 @@ func parseKeyRequest(r *http.Request, id uint64, clock clockwork.Clock) (etcdser
|
|||||||
`invalid value for "dir"`,
|
`invalid value for "dir"`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if quorum, err = getBool(r.Form, "quorum"); err != nil {
|
||||||
|
return emptyReq, etcdErr.NewRequestError(
|
||||||
|
etcdErr.EcodeInvalidField,
|
||||||
|
`invalid value for "quorum"`,
|
||||||
|
)
|
||||||
|
}
|
||||||
if stream, err = getBool(r.Form, "stream"); err != nil {
|
if stream, err = getBool(r.Form, "stream"); err != nil {
|
||||||
return emptyReq, etcdErr.NewRequestError(
|
return emptyReq, etcdErr.NewRequestError(
|
||||||
etcdErr.EcodeInvalidField,
|
etcdErr.EcodeInvalidField,
|
||||||
@ -442,11 +448,12 @@ func parseKeyRequest(r *http.Request, id uint64, clock clockwork.Clock) (etcdser
|
|||||||
PrevValue: pV,
|
PrevValue: pV,
|
||||||
PrevIndex: pIdx,
|
PrevIndex: pIdx,
|
||||||
PrevExist: pe,
|
PrevExist: pe,
|
||||||
Recursive: rec,
|
|
||||||
Since: wIdx,
|
|
||||||
Sorted: sort,
|
|
||||||
Stream: stream,
|
|
||||||
Wait: wait,
|
Wait: wait,
|
||||||
|
Since: wIdx,
|
||||||
|
Recursive: rec,
|
||||||
|
Sorted: sort,
|
||||||
|
Quorum: quorum,
|
||||||
|
Stream: stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
if pe != nil {
|
if pe != nil {
|
||||||
|
@ -167,6 +167,14 @@ func TestBadParseRequest(t *testing.T) {
|
|||||||
mustNewForm(t, "foo", url.Values{"dir": []string{"file"}}),
|
mustNewForm(t, "foo", url.Values{"dir": []string{"file"}}),
|
||||||
etcdErr.EcodeInvalidField,
|
etcdErr.EcodeInvalidField,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
mustNewForm(t, "foo", url.Values{"quorum": []string{"no"}}),
|
||||||
|
etcdErr.EcodeInvalidField,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mustNewForm(t, "foo", url.Values{"quorum": []string{"file"}}),
|
||||||
|
etcdErr.EcodeInvalidField,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
mustNewForm(t, "foo", url.Values{"stream": []string{"zzz"}}),
|
mustNewForm(t, "foo", url.Values{"stream": []string{"zzz"}}),
|
||||||
etcdErr.EcodeInvalidField,
|
etcdErr.EcodeInvalidField,
|
||||||
@ -305,6 +313,20 @@ func TestGoodParseRequest(t *testing.T) {
|
|||||||
Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
|
Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// quorum specified
|
||||||
|
mustNewForm(
|
||||||
|
t,
|
||||||
|
"foo",
|
||||||
|
url.Values{"quorum": []string{"true"}},
|
||||||
|
),
|
||||||
|
etcdserverpb.Request{
|
||||||
|
ID: 1234,
|
||||||
|
Method: "PUT",
|
||||||
|
Quorum: true,
|
||||||
|
Path: path.Join(etcdserver.StoreKeysPrefix, "/foo"),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// wait specified
|
// wait specified
|
||||||
mustNewRequest(t, "foo?wait=true"),
|
mustNewRequest(t, "foo?wait=true"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user