Revision: 4560 Author: btongminh Date: 2007-11-15 19:17:28 +0000 (Thu, 15 Nov 2007)
Log Message: ----------- Ensure that all received data is received
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-11-15 18:26:52 UTC (rev 4559) +++ trunk/pywikipedia/wikipedia.py 2007-11-15 19:17:28 UTC (rev 4560) @@ -3800,6 +3800,15 @@ 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) + else: if self.hostname() in config.authenticate.keys(): uo = authenticateURLopener