mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Only honor X-HTTP-Method-Override for POST requests.
This commit is contained in:
parent
716d86863f
commit
377dc2cda2
|
@ -21,11 +21,9 @@ For example, given the following form:
|
||||||
|
|
||||||
## HTTP header based method overriding
|
## HTTP header based method overriding
|
||||||
|
|
||||||
REST framework also supports method overriding via the `X-HTTP-Method-Override`
|
REST framework also supports method overriding via the semi-standard `X-HTTP-Method-Override` header. This can be useful if you are working with non-form content such as JSON and are working with an older web server and/or hosting provider that doesn't recognise particular HTTP methods such as `PATCH`. For example [Amazon Web Services ELB][aws_elb].
|
||||||
header. This is useful if you are working with non-form content such as
|
|
||||||
JSON and are working with an older web server and/or hosting provider
|
To use it, make a `POST` request, setting the `X-HTTP-Method-Override` header.
|
||||||
(e.g. [Amazon Web Services ELB][aws_elb]) that doesn't recognise particular
|
|
||||||
HTTP methods such as `PATCH`.
|
|
||||||
|
|
||||||
For example, making a `PATCH` request via `POST` in jQuery:
|
For example, making a `PATCH` request via `POST` in jQuery:
|
||||||
|
|
||||||
|
|
|
@ -233,11 +233,14 @@ class Request(object):
|
||||||
self.META.get('CONTENT_TYPE', ''))
|
self.META.get('CONTENT_TYPE', ''))
|
||||||
|
|
||||||
self._perform_form_overloading()
|
self._perform_form_overloading()
|
||||||
|
|
||||||
if not _hasattr(self, '_method'):
|
if not _hasattr(self, '_method'):
|
||||||
# Method wasn't overloaded by hidden form element, so look for
|
self._method = self._request.method
|
||||||
# method override in header. If not present default to raw HTTP method
|
|
||||||
|
if self._method == 'POST':
|
||||||
|
# Allow X-HTTP-METHOD-OVERRIDE header
|
||||||
self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE',
|
self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE',
|
||||||
self._request.method)
|
self._method)
|
||||||
|
|
||||||
def _load_stream(self):
|
def _load_stream(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user