mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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'·
This commit is contained in:
parent
b398d33c65
commit
915d14190e
9 changed files with 483 additions and 2 deletions
10
Lib/ssl.py
10
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue