[PATCH 1 of 2] httpclient: update to c5abd358e543 of httpplus

Augie Fackler raf at durin42.com
Sat May 19 09:34:43 CDT 2012


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1337378717 18000
# Node ID 59ec59b2c9e35ec4cdffd84e22e91af81bddca43
# Parent  9acb5cd19162bdb1053429df9ce9a13c2d15aea8
httpclient: update to c5abd358e543 of httpplus

diff --git a/mercurial/httpclient/__init__.py b/mercurial/httpclient/__init__.py
--- a/mercurial/httpclient/__init__.py
+++ b/mercurial/httpclient/__init__.py
@@ -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)
diff --git a/mercurial/httpclient/tests/util.py b/mercurial/httpclient/tests/util.py
--- a/mercurial/httpclient/tests/util.py
+++ b/mercurial/httpclient/tests/util.py
@@ -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)
 
 


More information about the Mercurial-devel mailing list