Show More
@@ -372,6 +372,10 b' class HTTPConnection(object):' | |||||
372 | else: |
|
372 | else: | |
373 | sock = socketutil.create_connection((self.host, self.port)) |
|
373 | sock = socketutil.create_connection((self.host, self.port)) | |
374 | if self.ssl: |
|
374 | if self.ssl: | |
|
375 | # This is the default, but in the case of proxied SSL | |||
|
376 | # requests the proxy logic above will have cleared | |||
|
377 | # blocking mode, so reenable it just to be safe. | |||
|
378 | sock.setblocking(1) | |||
375 | logger.debug('wrapping socket for ssl with options %r', |
|
379 | logger.debug('wrapping socket for ssl with options %r', | |
376 | self.ssl_opts) |
|
380 | self.ssl_opts) | |
377 | sock = socketutil.wrap_socket(sock, **self.ssl_opts) |
|
381 | sock = socketutil.wrap_socket(sock, **self.ssl_opts) |
@@ -58,6 +58,7 b' class MockSocket(object):' | |||||
58 | self.close_on_empty = False |
|
58 | self.close_on_empty = False | |
59 | self.sent = '' |
|
59 | self.sent = '' | |
60 | self.read_wait_sentinel = httpplus._END_HEADERS |
|
60 | self.read_wait_sentinel = httpplus._END_HEADERS | |
|
61 | self.blocking = True | |||
61 |
|
62 | |||
62 | def close(self): |
|
63 | def close(self): | |
63 | self.closed = True |
|
64 | self.closed = True | |
@@ -66,9 +67,11 b' class MockSocket(object):' | |||||
66 | self.sa = sa |
|
67 | self.sa = sa | |
67 |
|
68 | |||
68 | def setblocking(self, timeout): |
|
69 | def setblocking(self, timeout): | |
69 | assert timeout == 0 |
|
70 | self.blocking = bool(timeout) | |
70 |
|
71 | |||
71 | def recv(self, amt=-1): |
|
72 | def recv(self, amt=-1): | |
|
73 | # we only properly emulate non-blocking sockets | |||
|
74 | assert not self.blocking | |||
72 | if self.early_data: |
|
75 | if self.early_data: | |
73 | datalist = self.early_data |
|
76 | datalist = self.early_data | |
74 | elif not self.data: |
|
77 | elif not self.data: | |
@@ -136,6 +139,8 b' def mocksslwrap(sock, keyfile=None, cert' | |||||
136 | ssl_version=None, ca_certs=None, |
|
139 | ssl_version=None, ca_certs=None, | |
137 | do_handshake_on_connect=True, |
|
140 | do_handshake_on_connect=True, | |
138 | suppress_ragged_eofs=True): |
|
141 | suppress_ragged_eofs=True): | |
|
142 | assert sock.blocking, ('wrapping a socket with ssl requires that ' | |||
|
143 | 'it be in blocking mode.') | |||
139 | return MockSSLSocket(sock) |
|
144 | return MockSSLSocket(sock) | |
140 |
|
145 | |||
141 |
|
146 |
General Comments 0
You need to be logged in to leave comments.
Login now