diff mercurial/httpclient/__init__.py @ 14341:5c3de67e7402

httpclient: import revision b8c3511a8cae from py-nonblocking-http Fixes issues with SSL_ERROR_WANT_READ incorrectly breaking the response read.
author Augie Fackler <durin42@gmail.com>
date Thu, 12 May 2011 10:48:31 -0500
parents 9adbb5ef0964
children a75e0f4ba0ab
line wrap: on
line diff
--- a/mercurial/httpclient/__init__.py	Mon May 16 21:56:26 2011 +0200
+++ b/mercurial/httpclient/__init__.py	Thu May 12 10:48:31 2011 -0500
@@ -165,7 +165,13 @@
                 logger.info('timed out with timeout of %s', self._timeout)
                 raise HTTPTimeoutException('timeout reading data')
             logger.info('cl: %r body: %r', self._content_len, self._body)
-        data = self.sock.recv(INCOMING_BUFFER_SIZE)
+        try:
+            data = self.sock.recv(INCOMING_BUFFER_SIZE)
+        except socket.sslerror, e:
+            if e.args[0] != socket.SSL_ERROR_WANT_READ:
+                raise
+            logger.debug('SSL_WANT_READ in _select, should retry later')
+            return True
         logger.debug('response read %d data during _select', len(data))
         if not data:
             if not self.headers:
@@ -545,7 +551,14 @@
             # incoming data
             if r:
                 try:
-                    data = r[0].recv(INCOMING_BUFFER_SIZE)
+                    try:
+                        data = r[0].recv(INCOMING_BUFFER_SIZE)
+                    except socket.sslerror, e:
+                        if e.args[0] != socket.SSL_ERROR_WANT_READ:
+                            raise
+                        logger.debug(
+                            'SSL_WANT_READ while sending data, retrying...')
+                        continue
                     if not data:
                         logger.info('socket appears closed in read')
                         outgoing_headers = body = None