summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--M2Crypto/m2urllib2.py2
-rw-r--r--tests/te_chunked_response.txt11
-rw-r--r--tests/test_ssl.py22
3 files changed, 34 insertions, 1 deletions
diff --git a/M2Crypto/m2urllib2.py b/M2Crypto/m2urllib2.py
index efdebb5..acac92f 100644
--- a/M2Crypto/m2urllib2.py
+++ b/M2Crypto/m2urllib2.py
@@ -131,7 +131,7 @@ class HTTPSHandler(AbstractHTTPHandler):
r._decref_socketios = lambda: None
r.ssl = h.sock.ssl
r._timeout = -1.0
- r.recv_into = lambda b: SSL.Connection.recv_into(r, b)
+ r.recv_into = r.readinto
fp = socket.SocketIO(r, 'rb')
resp = addinfourl(fp, r.msg, req.get_full_url())
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: