Anonymous committed 2e2c142

Merged revisions 75134 via svnmerge from

r75134 | antoine.pitrou | 2009-09-29 19:48:18 +0200 (mar., 29 sept. 2009) | 4 lines

Issue #6790: Make it possible again to pass an `array.array` to
`httplib.HTTPConnection.send`. Patch by Kirk McDonald.

Comments (0)

Files changed (4)

 Req-sent-unread-response       _CS_REQ_SENT       <response_class>
+from array import array
 import socket
 from sys import py3kwarning
 from urlparse import urlsplit
             print "send:", repr(str)
-            if hasattr(str,'read') :
+            if hasattr(str,'read') and not isinstance(str, array):
                 if self.debuglevel > 0: print "sendIng a read()able"
                 while data:


+import array
 import httplib
 import StringIO
 import socket = ''
     def sendall(self, data):
- += data
+ += ''.join(data)
     def makefile(self, mode, bufsize=None):
         if mode != 'r' and mode != 'rb':
         conn.request('GET', '/foo', body)
+    def test_send(self):
+        expected = 'this is a test this is only a test'
+        conn = httplib.HTTPConnection('')
+        sock = FakeSocket(None)
+        conn.sock = sock
+        conn.send(expected)
+        self.assertEquals(expected,
+ = ''
+        conn.send(array.array('c', expected))
+        self.assertEquals(expected,
+ = ''
+        conn.send(StringIO.StringIO(expected))
+        self.assertEquals(expected,
     def test_chunked(self):
         chunked_start = (
             'HTTP/1.1 200 OK\r\n'
 Graham Matthews
 Dieter Maurer
 Arnaud Mazin
+Kirk McDonald
 Chris McDonough
 Greg McFarlane
 Alan McIntyre
+- Issue #6790: Make it possible again to pass an `array.array` to
+  `httplib.HTTPConnection.send`. Patch by Kirk McDonald.
 - Issue #6236, #6348: Fix various failures in the `io` module under AIX
   and other platforms, when using a non-gcc compiler. Patch by egreen.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.