mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +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
|
||||
|
||||
REST framework also supports method overriding via the `X-HTTP-Method-Override`
|
||||
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
|
||||
(e.g. [Amazon Web Services ELB][aws_elb]) that doesn't recognise particular
|
||||
HTTP methods such as `PATCH`.
|
||||
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].
|
||||
|
||||
To use it, make a `POST` request, setting the `X-HTTP-Method-Override` header.
|
||||
|
||||
For example, making a `PATCH` request via `POST` in jQuery:
|
||||
|
||||
|
|
|
@ -233,11 +233,14 @@ class Request(object):
|
|||
self.META.get('CONTENT_TYPE', ''))
|
||||
|
||||
self._perform_form_overloading()
|
||||
|
||||
if not _hasattr(self, '_method'):
|
||||
# Method wasn't overloaded by hidden form element, so look for
|
||||
# method override in header. If not present default to raw HTTP method
|
||||
self._method = self._request.method
|
||||
|
||||
if self._method == 'POST':
|
||||
# Allow X-HTTP-METHOD-OVERRIDE header
|
||||
self._method = self.META.get('HTTP_X_HTTP_METHOD_OVERRIDE',
|
||||
self._request.method)
|
||||
self._method)
|
||||
|
||||
def _load_stream(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user