Opened 14 years ago
Closed 14 years ago
#15353 closed (worksforme)
problem with django.middleware.gzip.GZipMiddleware — at Version 1
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | *.djangoproject.com | Version: | 1.2 |
Severity: | Keywords: | middleware gzip | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
In django.middleware.gzip.GZipMiddleware have a bug:
def process_response(self, request, response): # It's not worth compressing non-OK or really short responses. if response.status_code != 200 or len(response.content) < 200: return response
exist response without response.content!
when I use: (in url.py )
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
to binary files have a problem, do not exist response.content.
to solver the bug I add 'try' on code: try: if response.status_code != 200 or len(response.content) < 200: return response except: return response
In my vision the middlewere gzip don't have compress binary, because the browser is incompatible
Change History (1)
comment:1 by , 14 years ago
Description: | modified (diff) |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Please use preview when submitting code samples.
As for the bug itself: response *always* has a 'content' attribute. That's part of the basic contract of HttpResponse. The static serve view works fine for me with binary content -- because it doesn't just dump a file, it constructs a HttpResponse to contain the file content. I can't reproduce the problem as described, and what you're describing doesn't make a whole lot of sense.