Ticket #717: 717.diff

File 717.diff, 1.1 KB (added by Maniac <Maniac@…>, 18 years ago)

Patch

  • django/middleware/http.py

     
    11import datetime
     2import time
    23
    34class ConditionalGetMiddleware:
    45    """
     
    2425                response['Content-Length'] = '0'
    2526
    2627        if response.has_header('Last-Modified'):
    27             last_mod = response['Last-Modified']
    2828            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'
    3335
    3436        if request.META['REQUEST_METHOD'] == 'HEAD':
    3537            response.content = ''
Back to Top