contentType = headers.get('content-type', '') contentEncoding = headers.get('content-encoding', '') # Ensure that all sent data is received # In rare cases we found a douple Content-Length in the header. # We need to split it to get a value content_length = int(headers.get('content-length', '0').split(',')[0]) if content_length != len(text) and 'content-length' in headers: pywikibot.warning( u'len(text) does not match content-length: %s != %s' % (len(text), content_length)) return request(site, uri, retry, sysop, data, compress, no_hostname, cookie_only, back_response) if compress and contentEncoding == 'gzip': text = pywikibot.decompress_gzip(text) R = re.compile('charset=([^\'\";]+)') m = R.search(contentType) if m: charset = m.group(1) else: if pywikibot.verbose: pywikibot.warning(u"No character set found.") # UTF-8 as default charset = 'utf-8' # Check if this is the charset we expected try: site.checkCharset(charset) except AssertionError: if (not back_response) or verbose: