Author: brett.cannon
Date: Sat Nov  3 08:36:42 2007
New Revision: 58823

Modified:
   python/branches/py3k-pep3137/Lib/httplib.py
   python/branches/py3k-pep3137/Lib/test/test_httplib.py
Log:
Make HTTPConnectin.putheader() accept bytes/buffers and not use their string
representations.


Modified: python/branches/py3k-pep3137/Lib/httplib.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/httplib.py (original)
+++ python/branches/py3k-pep3137/Lib/httplib.py Sat Nov  3 08:36:42 2007
@@ -860,8 +860,12 @@
         if self.__state != _CS_REQ_STARTED:
             raise CannotSendHeader()
 
-        header = '%s: %s' % (header, value)
-        self._output(header.encode('ascii'))
+        if hasattr(header, 'encode'):
+            header = header.encode('ascii')
+        if hasattr(value, 'encode'):
+            value = value.encode('ascii')
+        header = header + b': ' + value
+        self._output(header)
 
     def endheaders(self):
         """Indicate that the last header line has been sent to the server."""

Modified: python/branches/py3k-pep3137/Lib/test/test_httplib.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_httplib.py       (original)
+++ python/branches/py3k-pep3137/Lib/test/test_httplib.py       Sat Nov  3 
08:36:42 2007
@@ -157,7 +157,8 @@
         sock = FakeSocket(body)
         conn.sock = sock
         conn.request('GET', '/foo', body)
-        self.assertTrue(sock.data.startswith(expected))
+        self.assertTrue(sock.data.startswith(expected), '%r != %r' %
+                (sock.data[:len(expected)], expected))
 
 class OfflineTest(TestCase):
     def test_responses(self):
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to