diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-12-19 10:49:52 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-12-19 10:49:52 (GMT) |
commit | 7bc0d872ddb023333acc05b7d038cdb74cfc047b (patch) | |
tree | 6225e5ecb0546a7826743510555c604751b238c7 /Lib/test/test_httplib.py | |
parent | 8a60e94802b04a838607b4aebba6fc8b70f7b87c (diff) | |
download | cpython-7bc0d872ddb023333acc05b7d038cdb74cfc047b.zip cpython-7bc0d872ddb023333acc05b7d038cdb74cfc047b.tar.gz cpython-7bc0d872ddb023333acc05b7d038cdb74cfc047b.tar.bz2 |
Issue3243 - Support iterable bodies in httplib. Patch contributions by Xuanji Li and Chris AtLee.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 7dae65d..79fc6cc 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -230,6 +230,22 @@ class BasicTest(TestCase): conn.send(io.BytesIO(expected)) self.assertEqual(expected, sock.data) + def test_send_iter(self): + expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ + b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \ + b'\r\nonetwothree' + + def body(): + yield b"one" + yield b"two" + yield b"three" + + conn = client.HTTPConnection('example.com') + sock = FakeSocket("") + conn.sock = sock + conn.request('GET', '/foo', body(), {'Content-Length': '11'}) + self.assertEquals(sock.data, expected) + def test_chunked(self): chunked_start = ( 'HTTP/1.1 200 OK\r\n' |