Django

Code

Changeset 5483

Show
Ignore:
Timestamp:
06/17/07 02:21:09 (1 year ago)
Author:
mtredinnick
Message:

Changed ETag computation to first check if an ETag header already exists in the
response.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/middleware/common.py

    r5417 r5483  
    1212 
    1313        - URL rewriting: Based on the APPEND_SLASH and PREPEND_WWW settings, 
    14           this middleware appends missing slashes and/or prepends missing "www."s. 
     14          this middleware appends missing slashes and/or prepends missing 
     15          "www."s. 
    1516 
    1617        - ETags: If the USE_ETAGS setting is set, ETags will be calculated from 
     
    7576        # Use ETags, if requested. 
    7677        if settings.USE_ETAGS: 
    77             etag = md5.new(response.content).hexdigest() 
     78            if response.has_header('ETag'): 
     79                etag = response['ETag'] 
     80            else: 
     81                etag = md5.new(response.content).hexdigest() 
    7882            if response.status_code >= 200 and response.status_code < 300 and request.META.get('HTTP_IF_NONE_MATCH') == etag: 
    7983                response = http.HttpResponseNotModified()