changeset 16774:69af967b6d6f

httpclient: update to c5abd358e543 of httpplus
author Augie Fackler <raf@durin42.com>
date Fri, 18 May 2012 17:05:17 -0500
parents d490edc71146
children e6af8676302f
files mercurial/httpclient/__init__.py mercurial/httpclient/tests/util.py
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httpclient/__init__.py	Mon May 21 00:20:05 2012 +0200
+++ b/mercurial/httpclient/__init__.py	Fri May 18 17:05:17 2012 -0500
@@ -372,6 +372,10 @@
         else:
             sock = socketutil.create_connection((self.host, self.port))
         if self.ssl:
+            # This is the default, but in the case of proxied SSL
+            # requests the proxy logic above will have cleared
+            # blocking mode, so reenable it just to be safe.
+            sock.setblocking(1)
             logger.debug('wrapping socket for ssl with options %r',
                          self.ssl_opts)
             sock = socketutil.wrap_socket(sock, **self.ssl_opts)
--- a/mercurial/httpclient/tests/util.py	Mon May 21 00:20:05 2012 +0200
+++ b/mercurial/httpclient/tests/util.py	Fri May 18 17:05:17 2012 -0500
@@ -58,6 +58,7 @@
         self.close_on_empty = False
         self.sent = ''
         self.read_wait_sentinel = httpplus._END_HEADERS
+        self.blocking = True
 
     def close(self):
         self.closed = True
@@ -66,9 +67,11 @@
         self.sa = sa
 
     def setblocking(self, timeout):
-        assert timeout == 0
+        self.blocking = bool(timeout)
 
     def recv(self, amt=-1):
+        # we only properly emulate non-blocking sockets
+        assert not self.blocking
         if self.early_data:
             datalist = self.early_data
         elif not self.data:
@@ -136,6 +139,8 @@
                 ssl_version=None, ca_certs=None,
                 do_handshake_on_connect=True,
                 suppress_ragged_eofs=True):
+    assert sock.blocking, ('wrapping a socket with ssl requires that '
+                           'it be in blocking mode.')
     return MockSSLSocket(sock)