This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients martin.panter
Date 2015-03-29.10:30:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427625023.61.0.148010223441.issue23804@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-03-29 10:30:23martin.pantersetrecipients: + martin.panter
2015-03-29 10:30:23martin.pantersetmessageid: <1427625023.61.0.148010223441.issue23804@psf.upfronthosting.co.za>
2015-03-29 10:30:23martin.panterlinkissue23804 messages
2015-03-29 10:30:23martin.pantercreate