mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1159 from jonboulle/1159_prevvalue_required
`prevValue` ignored when no value provided
This commit is contained in:
commit
510213b1c2
@ -218,6 +218,14 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
|
||||
)
|
||||
}
|
||||
|
||||
pV := r.FormValue("prevValue")
|
||||
if _, ok := r.Form["prevValue"]; ok && pV == "" {
|
||||
return emptyReq, etcdErr.NewRequestError(
|
||||
etcdErr.EcodeInvalidField,
|
||||
`"prevValue" cannot be empty`,
|
||||
)
|
||||
}
|
||||
|
||||
// prevExist is nullable, so leave it null if not specified
|
||||
var pe *bool
|
||||
if _, ok := r.Form["prevExist"]; ok {
|
||||
@ -236,7 +244,7 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
|
||||
Method: r.Method,
|
||||
Path: p,
|
||||
Val: r.FormValue("value"),
|
||||
PrevValue: r.FormValue("prevValue"),
|
||||
PrevValue: pV,
|
||||
PrevIndex: pIdx,
|
||||
PrevExist: pe,
|
||||
Recursive: rec,
|
||||
|
@ -147,6 +147,11 @@ func TestBadParseRequest(t *testing.T) {
|
||||
mustNewForm(t, "foo", url.Values{"stream": []string{"something"}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
},
|
||||
// prevValue cannot be empty
|
||||
{
|
||||
mustNewForm(t, "foo", url.Values{"prevValue": []string{""}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
},
|
||||
// wait is only valid with GET requests
|
||||
{
|
||||
mustNewMethodRequest(t, "HEAD", "foo?wait=true"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user