From 72e345aa4e6c0c8b92013437c9ed16d2b32e5ea8 Mon Sep 17 00:00:00 2001 From: deads2k Date: Fri, 20 Nov 2015 11:34:35 -0500 Subject: [PATCH] handle the HEAD verb correctly for authorization --- pkg/apiserver/handlers.go | 2 +- pkg/apiserver/handlers_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/apiserver/handlers.go b/pkg/apiserver/handlers.go index 2f2ced3372ca7..92d49ca9709f5 100644 --- a/pkg/apiserver/handlers.go +++ b/pkg/apiserver/handlers.go @@ -502,7 +502,7 @@ func (r *RequestInfoResolver) GetRequestInfo(req *http.Request) (RequestInfo, er switch req.Method { case "POST": requestInfo.Verb = "create" - case "GET": + case "GET", "HEAD": requestInfo.Verb = "get" case "PUT": requestInfo.Verb = "update" diff --git a/pkg/apiserver/handlers_test.go b/pkg/apiserver/handlers_test.go index 112692c6bf91b..3cc3d9149ceed 100644 --- a/pkg/apiserver/handlers_test.go +++ b/pkg/apiserver/handlers_test.go @@ -222,7 +222,9 @@ func TestGetAPIRequestInfo(t *testing.T) { {"GET", "/api/v1/namespaces/other/pods", "list", "api", "", "v1", "other", "pods", "", "", []string{"pods"}}, {"GET", "/api/v1/namespaces/other/pods/foo", "get", "api", "", "v1", "other", "pods", "", "foo", []string{"pods", "foo"}}, + {"HEAD", "/api/v1/namespaces/other/pods/foo", "get", "api", "", "v1", "other", "pods", "", "foo", []string{"pods", "foo"}}, {"GET", "/api/v1/pods", "list", "api", "", "v1", api.NamespaceAll, "pods", "", "", []string{"pods"}}, + {"HEAD", "/api/v1/pods", "list", "api", "", "v1", api.NamespaceAll, "pods", "", "", []string{"pods"}}, {"GET", "/api/v1/namespaces/other/pods/foo", "get", "api", "", "v1", "other", "pods", "", "foo", []string{"pods", "foo"}}, {"GET", "/api/v1/namespaces/other/pods", "list", "api", "", "v1", "other", "pods", "", "", []string{"pods"}},