def is_html(first_bytes):
 BOMS = [('\xef\xbb\xbf', u'utf-8'), ('\x00\x00\xfe\xff', u'utf-32-be'), ('\xff\xfe\x00\x00', u'utf-32-le'), ('\xff\xfe', u'utf-16-le'), ('\xfe\xff', u'utf-16-be')]
 for (bom, enc) in BOMS:
  if first_bytes.startswith(bom):
   s = first_bytes[len(bom):].decode(enc, u'replace')
   break
 else:
  s = first_bytes.decode(u'utf-8', u'replace')
 return re.match(u'^\\s*<', s)

def is_html ( first_bytes ) : BOMS = [ ( '\xef\xbb\xbf' , u'utf-8' ) , ( '\x00\x00\xfe\xff' , u'utf-32-be' ) , ( '\xff\xfe\x00\x00' , u'utf-32-le' ) , ( '\xff\xfe' , u'utf-16-le' ) , ( '\xfe\xff' , u'utf-16-be' ) ] for ( bom , enc ) in BOMS : if first_bytes . startswith ( bom ) : s = first_bytes [ len ( bom ) : ] . decode ( enc , u'replace' ) break else : s = first_bytes . decode ( u'utf-8' , u'replace' ) return re . match ( u'^\\s*<' , s )
ct_headers: sequence of content-type headers url: response url .