mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
An ssl-wrapped socket now returns '' on EOF, just like a regular
socket -- as suggested by Clarence Gardner. Fix httplib to comply with the new ssl-socket interface.
This commit is contained in:
parent
0072d5aa33
commit
42dd01add5
2 changed files with 11 additions and 10 deletions
|
@ -575,13 +575,16 @@ class FakeSocket:
|
|||
if mode != 'r' and mode != 'rb':
|
||||
raise UnimplementedFileMode()
|
||||
|
||||
msgbuf = ""
|
||||
msgbuf = []
|
||||
while 1:
|
||||
try:
|
||||
msgbuf = msgbuf + self.__ssl.read()
|
||||
buf = self.__ssl.read()
|
||||
except socket.sslerror, msg:
|
||||
break
|
||||
return StringIO(msgbuf)
|
||||
if buf == '':
|
||||
break
|
||||
msgbuf.append(buf)
|
||||
return StringIO("".join(msgbuf))
|
||||
|
||||
def send(self, stuff, flags = 0):
|
||||
return self.__ssl.write(stuff)
|
||||
|
@ -809,6 +812,7 @@ def test():
|
|||
|
||||
if hasattr(socket, 'ssl'):
|
||||
host = 'sourceforge.net'
|
||||
selector = '/projects/python'
|
||||
hs = HTTPS()
|
||||
hs.connect(host)
|
||||
hs.putrequest('GET', selector)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue