diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2014-06-11 01:54:30 (GMT) |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2014-06-11 01:54:30 (GMT) |
commit | 915d14190ee07b66e29b385943a942a51c825ae6 (patch) | |
tree | c822a64395af65a3f22f02aa5b87bd39c37a10b4 /Lib/ssl.py | |
parent | b398d33c65636aed68246179a4f6ae4b3fbcf182 (diff) | |
download | cpython-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.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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: |