mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
feat(server): make header-only requests work
This commit is contained in:
@@ -229,3 +229,27 @@ func TestV2WatchKeyInDir(t *testing.T) {
|
||||
assert.Equal(t, node["key"], "/keyindir", "")
|
||||
})
|
||||
}
|
||||
|
||||
// Ensures that HEAD could work.
|
||||
//
|
||||
// $ curl -I localhost:4001/v2/keys/foo/bar -> fail
|
||||
// $ curl -X PUT localhost:4001/v2/keys/foo/bar -d value=XXX
|
||||
// $ curl -I localhost:4001/v2/keys/foo/bar
|
||||
//
|
||||
func TestV2HeadKey(t *testing.T) {
|
||||
tests.RunServer(func(s *server.Server) {
|
||||
v := url.Values{}
|
||||
v.Set("value", "XXX")
|
||||
fullURL := fmt.Sprintf("%s%s", s.URL(), "/v2/keys/foo/bar")
|
||||
resp, _ := tests.Head(fullURL)
|
||||
assert.Equal(t, resp.StatusCode, http.StatusNotFound)
|
||||
assert.Equal(t, resp.ContentLength, -1)
|
||||
|
||||
resp, _ = tests.PutForm(fullURL, v)
|
||||
tests.ReadBody(resp)
|
||||
|
||||
resp, _ = tests.Head(fullURL)
|
||||
assert.Equal(t, resp.StatusCode, http.StatusOK)
|
||||
assert.Equal(t, resp.ContentLength, -1)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user