<s> from django . core . exceptions import MiddlewareNotUsed <EOL> from django . utils . http import http_date , parse_http_date_safe <EOL> class ConditionalGetMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_response ( self , request , response ) : <EOL> response [ '<STR_LIT>' ] = http_date ( ) <EOL> if not response . has_header ( '<STR_LIT>' ) : <EOL> response [ '<STR_LIT>' ] = str ( len ( response . content ) ) <EOL> if response . has_header ( '<STR_LIT>' ) : <EOL> if_none_match = request . META . get ( '<STR_LIT>' ) <EOL> if if_none_match == response [ '<STR_LIT>' ] : <EOL> response . status_code = <NUM_LIT> <EOL> if response . has_header ( '<STR_LIT>' ) : <EOL> if_modified_since = request . META . get ( '<STR_LIT>' ) <EOL> if if_modified_since is not None : <EOL> if_modified_since = parse_http_date_safe ( if_modified_since ) <EOL> if if_modified_since is not None : <EOL> last_modified = parse_http_date_safe ( response [ '<STR_LIT>' ] ) <EOL> if last_modified is not None and last_modified <= if_modified_since : <EOL> response . status_code = <NUM_LIT> <EOL> return response </s>
