<s> import datetime <EOL> class ConditionalGetMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_response ( self , request , response ) : <EOL> now = datetime . datetime . utcnow ( ) <EOL> response [ '<STR_LIT>' ] = now . strftime ( '<STR_LIT>' ) <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>' , None ) <EOL> if if_none_match == response [ '<STR_LIT>' ] : <EOL> response . status_code = <NUM_LIT> <EOL> response . content = '<STR_LIT>' <EOL> response [ '<STR_LIT>' ] = '<STR_LIT:0>' <EOL> if response . has_header ( '<STR_LIT>' ) : <EOL> last_mod = response [ '<STR_LIT>' ] <EOL> if_modified_since = request . META . get ( '<STR_LIT>' , None ) <EOL> if if_modified_since == response [ '<STR_LIT>' ] : <EOL> response . status_code = <NUM_LIT> <EOL> response . content = '<STR_LIT>' <EOL> response [ '<STR_LIT>' ] = '<STR_LIT:0>' <EOL> if request . method == '<STR_LIT>' : <EOL> response . content = '<STR_LIT>' <EOL> return response <EOL> class SetRemoteAddrFromForwardedFor ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_request ( self , request ) : <EOL> try : <EOL> real_ip = request . META [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> return None <EOL> else : <EOL> real_ip = real_ip . split ( "<STR_LIT:U+002C>" ) [ <NUM_LIT:0> ] <EOL> request . META [ '<STR_LIT>' ] = real_ip </s>
