From: <am...@us...> - 2008-12-18 11:05:20
|
Revision: 5776 http://jython.svn.sourceforge.net/jython/?rev=5776&view=rev Author: amak Date: 2008-12-18 11:05:16 +0000 (Thu, 18 Dec 2008) Log Message: ----------- Fix for broken SSL support. Thanks to dmbaggett for the patch. http://bugs.jython.org/issue1182 Modified Paths: -------------- branches/Release_2_2maint/jython/Lib/socket.py Modified: branches/Release_2_2maint/jython/Lib/socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/socket.py 2008-12-18 11:03:44 UTC (rev 5775) +++ branches/Release_2_2maint/jython/Lib/socket.py 2008-12-18 11:05:16 UTC (rev 5776) @@ -1320,6 +1320,8 @@ def __init__(self, plain_sock, keyfile=None, certfile=None): self.ssl_sock = self.make_ssl_socket(plain_sock) + self._in_buf = java.io.BufferedInputStream(self.ssl_sock.getInputStream()) + self._out_buf = java.io.BufferedOutputStream(self.ssl_sock.getOutputStream()) def make_ssl_socket(self, plain_socket, auto_close=0): java_net_socket = plain_socket._get_jsocket() @@ -1333,10 +1335,8 @@ return ssl_socket def read(self, n=4096): - # Probably needs some work on efficency - in_buf = java.io.BufferedInputStream(self.ssl_sock.getInputStream()) data = jarray.zeros(n, 'b') - m = in_buf.read(data, 0, n) + m = self._in_buf.read(data, 0, n) if m <= 0: return "" if m < n: @@ -1344,10 +1344,9 @@ return data.tostring() def write(self, s): - # Probably needs some work on efficency - out = java.io.BufferedOutputStream(self.ssl_sock.getOutputStream()) - out.write(s) - out.flush() + self._out_buf.write(s) + self._out_buf.flush() + return len(s) def _get_server_cert(self): return self.ssl_sock.getSession().getPeerCertificates()[0] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |