Revision: 4692 Author: btongminh Date: 2007-12-10 21:22:16 +0000 (Mon, 10 Dec 2007)
Log Message: ----------- Fix incomplete gets. (bug 1831698)
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-12-10 17:29:45 UTC (rev 4691) +++ trunk/pywikipedia/wikipedia.py 2007-12-10 21:22:16 UTC (rev 4692) @@ -3806,16 +3806,7 @@ return self.getUrl(path, retry, sysop, data, compress)
text = response.read() - contentType = response.getheader('Content-Type') - contentEncoding = response.getheader('Content-Encoding') - - # Ensure that all sent data is received - if int(response.getheader('Content-Length', '0')) != len(text): - output(u'Warning! len(text) does not match content-length: %s != %s' % \ - (len(text), response.getheader('Content-Length', '0'))) - self.conn.close() - self.conn.connect() - return self.getUrl(path, retry, sysop, data, compress) + headers = dict(response.getheaders())
else: if self.hostname() in config.authenticate.keys(): @@ -3867,11 +3858,20 @@ else: raise text = f.read() + + headers = f.info() + + contentType = headers.get('content-type', '') + contentEncoding = headers.get('content-encoding', '') + + # Ensure that all sent data is received + if int(headers.get('content-length', '0')) != len(text) and 'content-length' in headers: + output(u'Warning! len(text) does not match content-length: %s != %s' % \ + (len(text), headers.get('content-length'))) + self.conn.close() + self.conn.connect() + return self.getUrl(path, retry, sysop, data, compress)
- # Find charset in the content-type meta tag - contentType = f.info()['Content-Type'] - contentEncoding = f.headers.get('Content-Encoding') - if compress and contentEncoding == 'gzip': # Use cStringIO if available # TODO: rewrite gzip.py such that it supports unseekable fileobjects.
pywikipedia-l@lists.wikimedia.org