Fix Pulsar's default HTTP transport for poster hacking up urllib.

Behavior of urllib changes with respect of content length of mmap content after poster is loaded - is automatically loaded by Pulsar client as of 9207ecb43d81853da7a58cd5634683dc87991c4f (added as part of October 2014 stable release).

Enis has confirmed this fixes some problems in latest stable.
This commit is contained in:
John Chilton
2014-11-18 11:39:01 -05:00
parent 88293eb59a
commit 6b00a45508
+3 -1
View File
@@ -24,11 +24,13 @@ class Urllib2Transport(object):
input = None
try:
if input_path:
if getsize(input_path):
size = getsize(input_path)
if size:
input = open(input_path, 'rb')
data = mmap.mmap(input.fileno(), 0, access=mmap.ACCESS_READ)
else:
data = b""
request.add_header('Content-Length', str(size))
response = self._url_open(request, data)
finally:
if input: