<s> from django . utils . cache import get_conditional_response <EOL> from django . utils . http import http_date , parse_http_date_safe , unquote_etag <EOL> class ConditionalGetMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_response ( self , request , response ) : <EOL> response [ '<STR_LIT>' ] = http_date ( ) <EOL> if not response . streaming and not response . has_header ( '<STR_LIT>' ) : <EOL> response [ '<STR_LIT>' ] = str ( len ( response . content ) ) <EOL> etag = response . get ( '<STR_LIT>' ) <EOL> last_modified = response . get ( '<STR_LIT>' ) <EOL> if last_modified : <EOL> last_modified = parse_http_date_safe ( last_modified ) <EOL> if etag or last_modified : <EOL> return get_conditional_response ( <EOL> request , <EOL> etag = unquote_etag ( etag ) , <EOL> last_modified = last_modified , <EOL> response = response , <EOL> ) <EOL> return response </s>
