New submission from Martin Panter: The documentation claims that SSL socket objects provide some of the same methods as plain socket objects, including recv(), and that the “bufsize” parameter specifies the maximum amount of data to be received. With ordinary sockets, socket.recv(0) always seems to return zero bytes (b""), as expected. But not so with SSL sockets:
>>> import socket, ssl >>> s = ssl.wrap_socket(socket.create_connection(("localhost", 631))) >>> s.sendall(b"GET / HTTP/1.1\r\nHost: localhost\r\n\r\n") 35 >>> len(s.recv(0)) 263 >>> len(s.recv(0)) 1024 The call will hang or raise SSLWantReadError when no data is actually available. Looking at the code, the value of zero seems to be used as a placeholder for a default of 1024 in SSLObject.read(). Either the SSL module should be fixed to return no bytes (my preference), or the documentation needs to warn that the recv(0) is not supported, or does not work the same as for plain sockets. SSLSocket.read() might also be affected. ---------- components: Library (Lib) messages: 239483 nosy: vadmium priority: normal severity: normal status: open title: SSLSocket.recv(0) receives up to 1024 bytes type: behavior versions: Python 2.7, Python 3.4, Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23804> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com