#NEWLINE# def conditional_content_removal( request , response ) : #NEWLINE# #INDENT# '\n    Removes the content of responses for HEAD requests, 1xx, 204 and 304\n    responses. Ensures compliance with RFC 2616, section 4.3.\n    ' #NEWLINE# if ( ( 100 <= response . status_code < 200 ) or ( response . status_code in ( 204 , 304 ) ) ) : #NEWLINE# #INDENT# if response . streaming : #NEWLINE# #INDENT# response . streaming_content = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response . content = '' #NEWLINE# #UNINDENT# response [ 'Content-Length' ] = '0' #NEWLINE# #UNINDENT# if ( request . method == 'HEAD' ) : #NEWLINE# #INDENT# if response . streaming : #NEWLINE# #INDENT# response . streaming_content = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response . content = '' #NEWLINE# #UNINDENT# #UNINDENT# return response