summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDillon Dixon <dillondixon@gmail.com>2017-09-25 16:17:07 -0700
committerAshley Camba <ashwoods@gmail.com>2017-09-28 13:36:32 +0200
commit7a3fab9f5aa463e3643305844a1152f432b44758 (patch)
tree95cb210c761aaad09b7b7c2645003e527b22fa38
parenta00dedafdbcdc7e62c1357e125583dc1f94fa628 (diff)
downloadraven-7a3fab9f5aa463e3643305844a1152f432b44758.tar.gz
add application/octet-stream to non-cacheable types
-rw-r--r--raven/contrib/django/middleware/__init__.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/raven/contrib/django/middleware/__init__.py b/raven/contrib/django/middleware/__init__.py
index 809cd82..f7e80d8 100644
--- a/raven/contrib/django/middleware/__init__.py
+++ b/raven/contrib/django/middleware/__init__.py
@@ -121,15 +121,20 @@ SentryLogMiddleware = SentryMiddleware
class DjangoRestFrameworkCompatMiddleware(MiddlewareMixin):
+
+ non_cacheable_types = (
+ 'application/x-www-form-urlencoded',
+ 'multipart/form-data',
+ 'application/octet-stream'
+ )
+
def process_request(self, request):
"""
Access request.body, otherwise it might not be accessible later
after request has been read/streamed
"""
content_type = request.META.get('CONTENT_TYPE', '')
- if 'application/x-www-form-urlencoded' in content_type:
- pass
- elif 'multipart/form-data' in content_type:
- pass
- else:
- request.body # forces stream to be read into memory
+ for non_cacheable_type in self.non_cacheable_types:
+ if non_cacheable_type in content_type:
+ return
+ request.body # forces stream to be read into memory