def autovary(ignore=None, debug=False):
 request = cherrypy.serving.request
 req_h = request.headers
 request.headers = MonitoredHeaderMap()
 request.headers.update(req_h)
 if (ignore is None):
  ignore = set(['Content-Disposition', 'Content-Length', 'Content-Type'])
 def set_response_header():
  resp_h = cherrypy.serving.response.headers
  v = set([e.value for e in resp_h.elements('Vary')])
  if debug:
   cherrypy.log(('Accessed headers: %s' % request.headers.accessed_headers), 'TOOLS.AUTOVARY')
  v = v.union(request.headers.accessed_headers)
  v = v.difference(ignore)
  v = list(v)
  v.sort()
  resp_h['Vary'] = ', '.join(v)
 request.hooks.attach('before_finalize', set_response_header, 95)

def autovary ( ignore = None , debug = False ) : request = cherrypy . serving . request req_h = request . headers request . headers = MonitoredHeaderMap ( ) request . headers . update ( req_h ) if ( ignore is None ) : ignore = set ( [ 'Content-Disposition' , 'Content-Length' , 'Content-Type' ] ) def set_response_header ( ) : resp_h = cherrypy . serving . response . headers v = set ( [ e . value for e in resp_h . elements ( 'Vary' ) ] ) if debug : cherrypy . log ( ( 'Accessed headers: %s' % request . headers . accessed_headers ) , 'TOOLS.AUTOVARY' ) v = v . union ( request . headers . accessed_headers ) v = v . difference ( ignore ) v = list ( v ) v . sort ( ) resp_h [ 'Vary' ] = ', ' . join ( v ) request . hooks . attach ( 'before_finalize' , set_response_header , 95 )
auto-populate the vary response header based on request .