http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9846
Revision: 9846
Author: xqt
Date: 2012-01-29 16:13:50 +0000 (Sun, 29 Jan 2012)
Log Message:
-----------
In rare cases we found a douple Content-Length in the header. We need to split it to get a
value. Fix for postData().
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2012-01-28 21:46:05 UTC (rev 9845)
+++ trunk/pywikipedia/wikipedia.py 2012-01-29 16:13:50 UTC (rev 9846)
@@ -5412,10 +5412,15 @@
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')))
- return self.postData(address, data, contentType, sysop, compress, cookies)
+ # 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:
+ output(
+ u'Warning! len(text) does not match content-length: %s != %s'
+ % (len(text), content_length))
+ return self.postData(address, data, contentType, sysop, compress,
+ cookies)
if compress and contentEncoding == 'gzip':
text = decompress_gzip(text)
@@ -5571,10 +5576,13 @@
# 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
- if int(headers.get('content-length', '0').split(',')[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')))
- return self.getUrl(path, retry, sysop, data, compress, no_hostname,
cookie_only, back_response)
+ content_length = int(headers.get('content-length',
'0').split(',')[0])
+ if content_length != len(text) and 'content-length' in headers:
+ output(
+ u'Warning! len(text) does not match content-length: %s != %s'
+ % (len(text), content_length))
+ return self.getUrl(path, retry, sysop, data, compress, no_hostname,
+ cookie_only, back_response)
if compress and contentEncoding == 'gzip':
text = decompress_gzip(text)