#NEWLINE# def patch_vary_headers( response , newheaders ) : #NEWLINE# #INDENT# '\n    Adds (or updates) the "Vary" header in the given HttpResponse object.\n    newheaders is a list of header names that should be in "Vary". Existing\n    headers in "Vary" aren\'t removed.\n    ' #NEWLINE# vary = [ ] #NEWLINE# if response . has_header ( 'Vary' ) : #NEWLINE# #INDENT# vary = vary_delim_re . split ( response [ 'Vary' ] ) #NEWLINE# #UNINDENT# oldheaders = dict ( [ ( el . lower ( ) , 1 ) for el in vary ] ) #NEWLINE# for newheader in newheaders : #NEWLINE# #INDENT# if ( not ( newheader . lower ( ) in oldheaders ) ) : #NEWLINE# #INDENT# vary . append ( newheaders ) #NEWLINE# #UNINDENT# #UNINDENT# response [ 'Vary' ] = ', ' . join ( vary )