Message239483
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. |
|
Date |
User |
Action |
Args |
2015-03-29 10:30:23 | martin.panter | set | recipients:
+ martin.panter |
2015-03-29 10:30:23 | martin.panter | set | messageid: <1427625023.61.0.148010223441.issue23804@psf.upfronthosting.co.za> |
2015-03-29 10:30:23 | martin.panter | link | issue23804 messages |
2015-03-29 10:30:23 | martin.panter | create | |
|