def invalid_headers_reason(headers):
 if (headers is None):
  return 'Headers dictionary was None.'
 if (not isinstance(headers, dict)):
  return 'Invalid type for headers. Should be a dictionary.'
 for (k, v) in headers.iteritems():
  if (not isinstance(k, basestring)):
   return 'Header names should be strings.'
  if (not isinstance(v, basestring)):
   return 'Header values should be strings.'
  if (not is_ascii(k)):
   return 'Header name should be an ASCII string.'
  if (k.strip() not in HEADER_WHITELIST):
   return ('Header "%s" is not allowed.' % k.strip())

def invalid_headers_reason ( headers ) : if ( headers is None ) : return 'Headers dictionary was None.' if ( not isinstance ( headers , dict ) ) : return 'Invalid type for headers. Should be a dictionary.' for ( k , v ) in headers . iteritems ( ) : if ( not isinstance ( k , basestring ) ) : return 'Header names should be strings.' if ( not isinstance ( v , basestring ) ) : return 'Header values should be strings.' if ( not is_ascii ( k ) ) : return 'Header name should be an ASCII string.' if ( k . strip ( ) not in HEADER_WHITELIST ) : return ( 'Header "%s" is not allowed.' % k . strip ( ) )
determine reason why headers is invalid .