def request_fingerprint(request, include_headers=None):
 if include_headers:
  include_headers = tuple([h.lower() for h in sorted(include_headers)])
 cache = _fingerprint_cache.setdefault(request, {})
 if (include_headers not in cache):
  fp = hashlib.sha1()
  fp.update(request.method)
  fp.update(canonicalize_url(request.url))
  fp.update((request.body or ''))
  if include_headers:
   for hdr in include_headers:
    if (hdr in request.headers):
     fp.update(hdr)
     for v in request.headers.getlist(hdr):
      fp.update(v)
  cache[include_headers] = fp.hexdigest()
 return cache[include_headers]

def request_fingerprint ( request , include_headers = None ) : if include_headers : include_headers = tuple ( [ h . lower ( ) for h in sorted ( include_headers ) ] ) cache = _fingerprint_cache . setdefault ( request , { } ) if ( include_headers not in cache ) : fp = hashlib . sha1 ( ) fp . update ( request . method ) fp . update ( canonicalize_url ( request . url ) ) fp . update ( ( request . body or '' ) ) if include_headers : for hdr in include_headers : if ( hdr in request . headers ) : fp . update ( hdr ) for v in request . headers . getlist ( hdr ) : fp . update ( v ) cache [ include_headers ] = fp . hexdigest ( ) return cache [ include_headers ]
return the request fingerprint .