#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# if response . has_header ( 'Vary' ) : #NEWLINE# #INDENT# vary_headers = cc_delim_re . split ( response [ 'Vary' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# vary_headers = [ ] #NEWLINE# #UNINDENT# existing_headers = set ( [ header . lower ( ) for header in vary_headers ] ) #NEWLINE# additional_headers = [ newheader for newheader in newheaders if ( newheader . lower ( ) not in existing_headers ) ] #NEWLINE# response [ 'Vary' ] = ', ' . join ( ( vary_headers + additional_headers ) )