From 5ab7cc6e6be5445bc0d4ccc26f1ec84239af74d5 Mon Sep 17 00:00:00 2001 From: Nikolaus Schlemm Date: Sat, 18 May 2013 17:38:47 +0200 Subject: [PATCH] HEAD and OPTIONS should not be exposed as actions as discussed in https://github.com/nschlemm/django-rest-framework/commit/a42afa04c38afe25c9032b8ce37b572678b02cf1#commitcomment-3241476 --- rest_framework/tests/generics.py | 4 ++-- rest_framework/views.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rest_framework/tests/generics.py b/rest_framework/tests/generics.py index 014195ae7..d8556638a 100644 --- a/rest_framework/tests/generics.py +++ b/rest_framework/tests/generics.py @@ -125,7 +125,7 @@ class TestRootView(TestCase): 'actions': {} } # TODO: this is just a draft for fields' metadata - needs review and decision - for method in ('HEAD', 'GET', 'POST', 'OPTIONS'): + for method in ('GET', 'POST',): expected['actions'][method] = { 'text': { 'description': '', @@ -261,7 +261,7 @@ class TestInstanceView(TestCase): 'actions': {} } # TODO: this is just a draft idea for fields' metadata - needs review and decision - for method in ('HEAD', 'GET', 'PATCH', 'PUT', 'OPTIONS', 'DELETE'): + for method in ('GET', 'PATCH', 'PUT', 'DELETE'): expected['actions'][method] = { 'text': { 'description': '', diff --git a/rest_framework/views.py b/rest_framework/views.py index 719df4284..c5b89a024 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -71,6 +71,10 @@ class APIView(View): actions = {} for method in self.allowed_methods: + # skip HEAD and OPTIONS + if method in ('HEAD', 'OPTIONS'): + continue + cloned_request = clone_request(request, method) try: self.check_permissions(cloned_request)