Index: Lib/httplib.py =================================================================== --- Lib/httplib.py (revision 75065) +++ Lib/httplib.py (working copy) @@ -66,6 +66,7 @@ Req-sent-unread-response _CS_REQ_SENT """ +from array import array import socket from sys import py3kwarning from urlparse import urlsplit @@ -732,7 +733,7 @@ print "send:", repr(str) try: blocksize=8192 - if hasattr(str,'read') : + if hasattr(str,'read') and not isinstance(str, array): if self.debuglevel > 0: print "sendIng a read()able" data=str.read(blocksize) while data: Index: Lib/test/test_httplib.py =================================================================== --- Lib/test/test_httplib.py (revision 75065) +++ Lib/test/test_httplib.py (working copy) @@ -1,3 +1,4 @@ +import array import httplib import StringIO import socket @@ -15,7 +16,7 @@ self.data = '' def sendall(self, data): - self.data += data + self.data += ''.join(data) def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': @@ -162,6 +163,20 @@ conn.request('GET', '/foo', body) self.assertTrue(sock.data.startswith(expected)) + def test_send(self): + expected = 'this is a test this is only a test' + conn = httplib.HTTPConnection('example.com') + sock = FakeSocket(None) + conn.sock = sock + conn.send(expected) + self.assertEquals(expected, sock.data) + sock.data = '' + conn.send(array.array('c', expected)) + self.assertEquals(expected, sock.data) + sock.data = '' + conn.send(StringIO.StringIO(expected)) + self.assertEquals(expected, sock.data) + def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n'