Code

Ticket #12788: fix_middleware_http.3.diff

File fix_middleware_http.3.diff, 1.0 KB (added by penzoil <fredericbochmann@…>, 4 years ago)
Line 
1Index: django/middleware/http.py
2===================================================================
3--- django/middleware/http.py   (revision 12385)
4+++ django/middleware/http.py   (working copy)
5@@ -16,7 +16,8 @@
6 
7         if response.has_header('ETag'):
8             if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)
9-            if if_none_match == response['ETag']:
10+            content_length = request.META.get('CONTENT_LENGTH', 0)
11+            if if_none_match == response['ETag'] and content_length != 0:
12                 # Setting the status is enough here. The response handling path
13                 # automatically removes content for this status code (in
14                 # http.conditional_content_removal()).
15@@ -48,4 +49,4 @@
16         warnings.warn("SetRemoteAddrFromForwardedFor has been removed. "
17                       "See the Django 1.1 release notes for details.",
18                       category=DeprecationWarning)
19-        raise MiddlewareNotUsed()
20\ No newline at end of file
21+        raise MiddlewareNotUsed()