diff options
-rw-r--r-- | Lib/httplib.py | 2 | ||||
-rw-r--r-- | Lib/test/test_httplib.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index eb10ebad5d..526509c01f 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -915,7 +915,7 @@ class HTTPConnection: if self.__state != _CS_REQ_STARTED: raise CannotSendHeader() - hdr = '%s: %s' % (header, '\r\n\t'.join(values)) + hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values])) self._output(hdr) def endheaders(self, message_body=None): diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 435a9fc8b8..74301ff39a 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -1,3 +1,4 @@ +import httplib import array import httplib import StringIO @@ -64,8 +65,6 @@ class HeaderTests(TestCase): # Some headers are added automatically, but should not be added by # .request() if they are explicitly set. - import httplib - class HeaderCountingBuffer(list): def __init__(self): self.count = {} @@ -91,6 +90,13 @@ class HeaderTests(TestCase): conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) + def test_putheader(self): + conn = httplib.HTTPConnection('example.com') + conn.sock = FakeSocket(None) + conn.putrequest('GET','/') + conn.putheader('Content-length',42) + self.assertTrue('Content-length: 42' in conn._buffer) + class BasicTest(TestCase): def test_status_lines(self): # Test HTTP status lines |