summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2014-06-11 01:54:30 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2014-06-11 01:54:30 (GMT)
commit915d14190ee07b66e29b385943a942a51c825ae6 (patch)
treec822a64395af65a3f22f02aa5b87bd39c37a10b4 /Lib/test/test_ssl.py
parentb398d33c65636aed68246179a4f6ae4b3fbcf182 (diff)
downloadcpython-915d14190ee07b66e29b385943a942a51c825ae6.zip
cpython-915d14190ee07b66e29b385943a942a51c825ae6.tar.gz
cpython-915d14190ee07b66e29b385943a942a51c825ae6.tar.bz2
fix issue #17552: add socket.sendfile() method allowing to send a file over a socket by using high-performance os.sendfile() on UNIX. Patch by Giampaolo Rodola'ยท
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index f72fb15..bdde9ac 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -2957,6 +2957,23 @@ else:
self.assertRaises(ValueError, s.read, 1024)
self.assertRaises(ValueError, s.write, b'hello')
+ def test_sendfile(self):
+ TEST_DATA = b"x" * 512
+ with open(support.TESTFN, 'wb') as f:
+ f.write(TEST_DATA)
+ self.addCleanup(support.unlink, support.TESTFN)
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERTFILE)
+ context.load_cert_chain(CERTFILE)
+ server = ThreadedEchoServer(context=context, chatty=False)
+ with server:
+ with context.wrap_socket(socket.socket()) as s:
+ s.connect((HOST, server.port))
+ with open(support.TESTFN, 'rb') as file:
+ s.sendfile(file)
+ self.assertEqual(s.recv(1024), TEST_DATA)
+
def test_main(verbose=False):
if support.verbose: