diff options
| author | tom christie tom@tomchristie.com | 2011-02-01 21:16:34 +0000 |
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-02-01 21:16:34 +0000 |
| commit | 196c21f37632e213702995651fd739426b6ee13a (patch) | |
| tree | 40ed01cc3f421d17c7e8877f8fcb6efdbaeed199 /djangorestframework/resource.py | |
| parent | e19816598973cb40b2d331d61c399ed90c81f430 (diff) | |
| download | django-rest-framework-196c21f37632e213702995651fd739426b6ee13a.tar.bz2 | |
Browser UA tests passing
Diffstat (limited to 'djangorestframework/resource.py')
| -rw-r--r-- | djangorestframework/resource.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/djangorestframework/resource.py b/djangorestframework/resource.py index d06d51b0..6277d22e 100644 --- a/djangorestframework/resource.py +++ b/djangorestframework/resource.py @@ -17,6 +17,8 @@ import re __all__ = ['Resource'] +_MSIE_USER_AGENT = re.compile(r'^Mozilla/[0-9]+\.[0-9]+ \([^)]*; MSIE [0-9]+\.[0-9]+[a-z]?;[^)]*\)(?!.* Opera )') + class Resource(object): """Handles incoming requests and maps them to REST operations, @@ -57,6 +59,7 @@ class Resource(object): CONTENT_PARAM = '_content' # Allow override of body content in form params (allows sending arbitrary content with standard forms) CSRF_PARAM = 'csrfmiddlewaretoken' # Django's CSRF token used in form params + _MUNGE_IE_ACCEPT_HEADER = True def __new__(cls, *args, **kwargs): """Make the class callable so it can be used as a Django view.""" @@ -312,6 +315,8 @@ class Resource(object): if self.ACCEPT_QUERY_PARAM and request.GET.get(self.ACCEPT_QUERY_PARAM, None): # Use _accept parameter override accept_list = [request.GET.get(self.ACCEPT_QUERY_PARAM)] + elif self._MUNGE_IE_ACCEPT_HEADER and request.META.has_key('HTTP_USER_AGENT') and _MSIE_USER_AGENT.match(request.META['HTTP_USER_AGENT']): + accept_list = ['text/html', '*/*'] elif request.META.has_key('HTTP_ACCEPT'): # Use standard HTTP Accept negotiation accept_list = request.META["HTTP_ACCEPT"].split(',') |
