Django

Code

Ticket #7228: 7228.diff

File 7228.diff, 1.3 kB (added by Simon Greenhill, 5 months ago)

Patch implementing skjohn's suggestion

  • django_src/django/middleware/common.py

    old new  
    108108            if response.has_header('ETag'): 
    109109                etag = response['ETag'] 
    110110            else: 
    111                 etag = md5.new(response.content).hexdigest() 
     111                etag = '"%s"' % md5.new(response.content).hexdigest()  
    112112            if response.status_code >= 200 and response.status_code < 300 and request.META.get('HTTP_IF_NONE_MATCH') == etag: 
    113113                cookies = response.cookies 
    114114                response = http.HttpResponseNotModified() 
  • django_src/django/utils/cache.py

    old new  
    104104    if cache_timeout < 0: 
    105105        cache_timeout = 0 # Can't have max-age negative 
    106106    if not response.has_header('ETag'): 
    107         response['ETag'] = md5.new(response.content).hexdigest() 
     107        response['ETag'] = '"%s"' % md5.new(response.content).hexdigest()  
    108108    if not response.has_header('Last-Modified'): 
    109109        response['Last-Modified'] = http_date() 
    110110    if not response.has_header('Expires'):