mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1164 from jonboulle/1164_dirs
Unable to create directories
This commit is contained in:
commit
db3afb18df
@ -188,7 +188,7 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var rec, sort, wait, stream bool
|
||||
var rec, sort, wait, dir, stream bool
|
||||
if rec, err = getBool(r.Form, "recursive"); err != nil {
|
||||
return emptyReq, etcdErr.NewRequestError(
|
||||
etcdErr.EcodeInvalidField,
|
||||
@ -207,6 +207,13 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
|
||||
`invalid value for "wait"`,
|
||||
)
|
||||
}
|
||||
// TODO(jonboulle): define what parameters dir is/isn't compatible with?
|
||||
if dir, err = getBool(r.Form, "dir"); err != nil {
|
||||
return emptyReq, etcdErr.NewRequestError(
|
||||
etcdErr.EcodeInvalidField,
|
||||
`invalid value for "dir"`,
|
||||
)
|
||||
}
|
||||
if stream, err = getBool(r.Form, "stream"); err != nil {
|
||||
return emptyReq, etcdErr.NewRequestError(
|
||||
etcdErr.EcodeInvalidField,
|
||||
@ -247,6 +254,7 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
|
||||
Method: r.Method,
|
||||
Path: p,
|
||||
Val: r.FormValue("value"),
|
||||
Dir: dir,
|
||||
PrevValue: pV,
|
||||
PrevIndex: pIdx,
|
||||
PrevExist: pe,
|
||||
|
@ -102,7 +102,7 @@ func TestBadParseRequest(t *testing.T) {
|
||||
mustNewForm(t, "foo", url.Values{"ttl": []string{"-1"}}),
|
||||
etcdErr.EcodeTTLNaN,
|
||||
},
|
||||
// bad values for recursive, sorted, wait, prevExist, stream
|
||||
// bad values for recursive, sorted, wait, prevExist, dir, stream
|
||||
{
|
||||
mustNewForm(t, "foo", url.Values{"recursive": []string{"hahaha"}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
@ -139,6 +139,14 @@ func TestBadParseRequest(t *testing.T) {
|
||||
mustNewForm(t, "foo", url.Values{"prevExist": []string{"#2"}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
},
|
||||
{
|
||||
mustNewForm(t, "foo", url.Values{"dir": []string{"no"}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
},
|
||||
{
|
||||
mustNewForm(t, "foo", url.Values{"dir": []string{"file"}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
},
|
||||
{
|
||||
mustNewForm(t, "foo", url.Values{"stream": []string{"zzz"}}),
|
||||
etcdErr.EcodeInvalidField,
|
||||
@ -305,6 +313,26 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
Expiration: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
// dir specified
|
||||
mustNewRequest(t, "foo?dir=true"),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
Method: "GET",
|
||||
Dir: true,
|
||||
Path: "/foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
// dir specified negatively
|
||||
mustNewRequest(t, "foo?dir=false"),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
Method: "GET",
|
||||
Dir: false,
|
||||
Path: "/foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
// prevExist should be non-null if specified
|
||||
mustNewForm(
|
||||
|
Loading…
x
Reference in New Issue
Block a user