summaryrefslogtreecommitdiffstats
path: root/Lib/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/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/ssl.py')
-rw-r--r--Lib/ssl.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 8f12513..efea02a 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -700,6 +700,16 @@ class SSLSocket(socket):
else:
return socket.sendall(self, data, flags)
+ def sendfile(self, file, offset=0, count=None):
+ """Send a file, possibly by using os.sendfile() if this is a
+ clear-text socket. Return the total number of bytes sent.
+ """
+ if self._sslobj is None:
+ # os.sendfile() works with plain sockets only
+ return super().sendfile(file, offset, count)
+ else:
+ return self._sendfile_use_send(file, offset, count)
+
def recv(self, buflen=1024, flags=0):
self._checkClosed()
if self._sslobj: