Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit 7a3fab9

Browse files
Dillon Dixonashwoods
authored andcommitted
add application/octet-stream to non-cacheable types
1 parent a00deda commit 7a3fab9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

raven/contrib/django/middleware/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,20 @@ def request_finished(self, **kwargs):
121121

122122

123123
class DjangoRestFrameworkCompatMiddleware(MiddlewareMixin):
124+
125+
non_cacheable_types = (
126+
'application/x-www-form-urlencoded',
127+
'multipart/form-data',
128+
'application/octet-stream'
129+
)
130+
124131
def process_request(self, request):
125132
"""
126133
Access request.body, otherwise it might not be accessible later
127134
after request has been read/streamed
128135
"""
129136
content_type = request.META.get('CONTENT_TYPE', '')
130-
if 'application/x-www-form-urlencoded' in content_type:
131-
pass
132-
elif 'multipart/form-data' in content_type:
133-
pass
134-
else:
135-
request.body # forces stream to be read into memory
137+
for non_cacheable_type in self.non_cacheable_types:
138+
if non_cacheable_type in content_type:
139+
return
140+
request.body # forces stream to be read into memory

0 commit comments

Comments
 (0)