Ticket #717: 717.diff
File 717.diff, 1.1 KB (added by , 19 years ago) |
---|
-
django/middleware/http.py
1 1 import datetime 2 import time 2 3 3 4 class ConditionalGetMiddleware: 4 5 """ … … 24 25 response['Content-Length'] = '0' 25 26 26 27 if response.has_header('Last-Modified'): 27 last_mod = response['Last-Modified']28 28 if_modified_since = request.META.get('HTTP_IF_MODIFIED_SINCE', None) 29 if if_modified_since == response['Last-Modified']: 30 response.status_code = 304 31 response.content = '' 32 response['Content-Length'] = '0' 29 if if_modified_since: 30 format = '%a, %d %b %Y %H:%M:%S GMT' 31 if time.strptime(response['Last-Modified'], format) <= time.strptime(if_modified_since, format): 32 response.status_code = 304 33 response.content = '' 34 response['Content-Length'] = '0' 33 35 34 36 if request.META['REQUEST_METHOD'] == 'HEAD': 35 37 response.content = ''