diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/te_chunked_response.txt | 11 | ||||
-rw-r--r-- | tests/test_ssl.py | 22 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/te_chunked_response.txt b/tests/te_chunked_response.txt new file mode 100644 index 0000000..f7eaadd --- /dev/null +++ b/tests/te_chunked_response.txt @@ -0,0 +1,11 @@ +HTTP/1.1 200 ok
+Content-Type: text/plain
+Transfer-Encoding: chunked
+
+4
+foo +
+7
+foobar +
+0
diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 3140b33..459531a 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -1004,6 +1004,27 @@ class Urllib2SSLClientTestCase(BaseSSLClientTestCase): self.stop_server(pid) +class Urllib2TEChunkedSSLClientTestCase(BaseSSLClientTestCase): + """Test a response with "Transfer-Encoding: chunked".""" + + def setUp(self): + super(Urllib2TEChunkedSSLClientTestCase, self).setUp() + self.args = ['s_server', '-quiet', '-HTTP', + '-accept', str(self.srv_port)] + + def test_transfer_encoding_chunked(self): + pid = self.start_server(self.args) + try: + url = 'https://%s:%s/te_chunked_response.txt' % (srv_host, + self.srv_port) + o = m2urllib2.build_opener() + u = o.open(url) + data = u.read() + self.assertEqual(b'foo\nfoobar\n', data) + finally: + self.stop_server(pid) + + @unittest.skipUnless(util.py27plus, "Twisted doesn't test well with Python 2.6") class TwistedSSLClientTestCase(BaseSSLClientTestCase): @@ -1166,6 +1187,7 @@ def suite(): suite.addTest(unittest.makeSuite(HttpslibSSLSNIClientTestCase)) suite.addTest(unittest.makeSuite(UrllibSSLClientTestCase)) suite.addTest(unittest.makeSuite(Urllib2SSLClientTestCase)) + suite.addTest(unittest.makeSuite(Urllib2TEChunkedSSLClientTestCase)) suite.addTest(unittest.makeSuite(MiscSSLClientTestCase)) suite.addTest(unittest.makeSuite(FtpslibTestCase)) try: |