diff options
| author | Tom Christie | 2012-01-11 14:48:22 +0000 |
|---|---|---|
| committer | Tom Christie | 2012-01-11 14:48:22 +0000 |
| commit | 42563d9fbc396c825a2d443302a3ce741ec7e2c6 (patch) | |
| tree | 3bccb223337fce85d9558d5397df54403efadcda /djangorestframework/views.py | |
| parent | ac51210594cccbcd9af59658118c4e4ad6d81760 (diff) | |
| download | django-rest-framework-42563d9fbc396c825a2d443302a3ce741ec7e2c6.tar.bz2 | |
Remove explicit handling of 'OPTIONS' method, just raise the response, rather than returning it.
Diffstat (limited to 'djangorestframework/views.py')
| -rw-r--r-- | djangorestframework/views.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/djangorestframework/views.py b/djangorestframework/views.py index eb742743..12c94bb6 100644 --- a/djangorestframework/views.py +++ b/djangorestframework/views.py @@ -119,7 +119,6 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView): """ self.headers[field] = value - # Note: session based authentication is explicitly CSRF validated, # all other authentication is CSRF exempt. @csrf_exempt @@ -153,13 +152,8 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView): else: response = Response(status.HTTP_204_NO_CONTENT) - if request.method == 'OPTIONS': - # do not filter the response for HTTP OPTIONS, else the response fields are lost, - # as they do not correspond with model fields - response.cleaned_content = response.raw_content - else: - # Pre-serialize filtering (eg filter complex objects into natively serializable types) - response.cleaned_content = self.filter_response(response.raw_content) + # Pre-serialize filtering (eg filter complex objects into natively serializable types) + response.cleaned_content = self.filter_response(response.raw_content) except ErrorResponse, exc: response = exc.response @@ -179,7 +173,10 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView): for name, field in form.fields.iteritems(): field_name_types[name] = field.__class__.__name__ response_obj['fields'] = field_name_types - return response_obj + # Note 'ErrorResponse' is misleading, it's just any response + # that should be rendered and returned immediately, without any + # response filtering. + raise ErrorResponse(status.HTTP_200_OK, response_obj) class ModelView(View): |
