diff options
author | Bill Janssen <janssen@parc.com> | 2008-02-01 02:16:46 (GMT) |
---|---|---|
committer | Bill Janssen <janssen@parc.com> | 2008-02-01 02:16:46 (GMT) |
commit | a7712090f78d19d0711553d58e403c9fa44474a8 (patch) | |
tree | 9f322fa60cabe6d00c05028fa38a5ec44a2b13b4 /Lib | |
parent | db0a9b37b66fb45923fc9cd96b41d72f443f34e1 (diff) | |
download | cpython-a7712090f78d19d0711553d58e403c9fa44474a8.zip cpython-a7712090f78d19d0711553d58e403c9fa44474a8.tar.gz cpython-a7712090f78d19d0711553d58e403c9fa44474a8.tar.bz2 |
fix bug 1482: IMAP4 SSL isn't working
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/imaplib.py | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 6cd1e2f..57046d3 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -1145,55 +1145,10 @@ else: """ self.host = host self.port = port - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.connect((host, port)) - self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile) - - - def read(self, size): - """Read 'size' bytes from remote.""" - # sslobj.read() sometimes returns < size bytes - chunks = [] - read = 0 - while read < size: - data = self.sslobj.read(size-read) - read += len(data) - chunks.append(data) - - return ''.join(chunks) - - - def readline(self): - """Read line from remote.""" - line = [] - while 1: - char = self.sslobj.read(1) - line.append(char) - if char == "\n": return ''.join(line) - - - def send(self, data): - """Send data to remote.""" - bytes = len(data) - while bytes > 0: - sent = self.sslobj.write(data) - if sent == bytes: - break # avoid copy - data = data[sent:] - bytes = bytes - sent - - - def shutdown(self): - """Close I/O established in "open".""" - self.sock.close() - - - def socket(self): - """Return socket instance used to connect to IMAP4 server. - - socket = <instance>.socket() - """ - return self.sock + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((host, port)) + self.sock = ssl.wrap_socket(sock, self.keyfile, self.certfile) + self.file = self.sock.makefile('rb') def ssl(self): @@ -1201,7 +1156,7 @@ else: ssl = ssl.wrap_socket(<instance>.socket) """ - return self.sslobj + return self.sock __all__.append("IMAP4_SSL") |