Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix KeyError in Middleware occurring in Django 1.5 #171

Merged
merged 1 commit into from Mar 1, 2013

Conversation

Projects
None yet
2 participants
Contributor

markotibold commented Feb 28, 2013

Since Django 1.5, for some reason static files that are served when DEBUG
is True, no longer have a Content-Type set when when the server tries to
return a 304 - Not Modified, and thus may result in a
KeyError. This commit fixes that.

Since Django 1.5, for some reason static files that are served when D…
…EBUG

is True, no longer have a Content-Type set when when the server tries to
return a `304 - Not Modified`, and thus may result in a
KeyError. This commit fixes that.

markotibold added a commit that referenced this pull request Mar 1, 2013

Merge pull request #171 from markotibold/static-serve
Fix KeyError in Middleware occurring in Django 1.5

@markotibold markotibold merged commit 256b586 into django-fiber:dev Mar 1, 2013

1 check passed

default The Travis build passed
Details

@slollo slollo commented on the diff Nov 26, 2013

fiber/middleware.py
@@ -12,6 +12,16 @@
from .utils.import_util import import_element
+def is_non_html(response):
+ """
+ Returns True if the response has no Content-type set or is not `text/html`
+ or not `application/xhtml+xml`.
+ """
+ content_type = response.get('Content-Type')
+ if content_type is None or content_type.split(';')[0] not in ('text/html', 'application/xhtml+xml'):
@slollo

slollo Nov 26, 2013

replace 'if' to 'return' and remove next line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment