allow urllib2 to be passed unicode data to send (#923)

This commit is contained in:
Damien Elmes 2013-07-03 04:48:52 +09:00
parent 2754ead0a4
commit a1ca03ee17

View file

@ -413,6 +413,8 @@ def _incrementalSend(self, data):
raise httplib.NotConnected()
# if it's not a file object, make it one
if not hasattr(data, 'read'):
if isinstance(data, unicode):
data = data.encode("utf8")
data = StringIO(data)
while 1:
block = data.read(CHUNK_SIZE)