aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/response.py
diff options
context:
space:
mode:
authorTom Christie2012-09-06 16:28:11 +0100
committerTom Christie2012-09-06 16:28:11 +0100
commit9dc7270cced6be898ff1c3a8855bf196bd89b912 (patch)
tree26fbcf87f085964f3fa1ac7ead9c3f3e20f0bc5c /djangorestframework/response.py
parentb79833ecddcea788b4a8d8901bd25f0afe83bbf7 (diff)
downloaddjango-rest-framework-9dc7270cced6be898ff1c3a8855bf196bd89b912.tar.bz2
Move settings stuff actually into settings
Diffstat (limited to 'djangorestframework/response.py')
-rw-r--r--djangorestframework/response.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/djangorestframework/response.py b/djangorestframework/response.py
index f8b3504e..71b08a04 100644
--- a/djangorestframework/response.py
+++ b/djangorestframework/response.py
@@ -38,7 +38,7 @@ class Response(SimpleTemplateResponse):
- renderers(list/tuple). The renderers to use for rendering the response content.
"""
- _ACCEPT_QUERY_PARAM = '_accept' # Allow override of Accept header in URL query params
+ _ACCEPT_QUERY_PARAM = api_settings.URL_ACCEPT_OVERRIDE
_IGNORE_IE_ACCEPT_HEADER = True
def __init__(self, content=None, status=None, headers=None, view=None, request=None, renderers=None):
@@ -107,13 +107,16 @@ class Response(SimpleTemplateResponse):
"""
request = self.request
- if self._ACCEPT_QUERY_PARAM and request.GET.get(self._ACCEPT_QUERY_PARAM, None):
+ if (self._ACCEPT_QUERY_PARAM and
+ request.GET.get(self._ACCEPT_QUERY_PARAM, None)):
# Use _accept parameter override
return [request.GET.get(self._ACCEPT_QUERY_PARAM)]
elif (self._IGNORE_IE_ACCEPT_HEADER and
'HTTP_USER_AGENT' in request.META and
- MSIE_USER_AGENT_REGEX.match(request.META['HTTP_USER_AGENT'])):
- # Ignore MSIE's broken accept behavior and do something sensible instead
+ MSIE_USER_AGENT_REGEX.match(request.META['HTTP_USER_AGENT']) and
+ request.META.get('HTTP_X_REQUESTED_WITH', '') != 'XMLHttpRequest'):
+ # Ignore MSIE's broken accept behavior except for AJAX requests
+ # and do something sensible instead
return ['text/html', '*/*']
elif 'HTTP_ACCEPT' in request.META:
# Use standard HTTP Accept negotiation