Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The last comment on the Python issue Eiyrioü von Kauyf mentions above is the solution I implemented in my <a href="https://github.com/mikewebkist/mechanize/commit/5d41022b6eec58a6bdd7704841bdffe731871bd5" rel="nofollow">forked version of mechanize</a>. The diff of mechanize/_opener.py follows. It fixes mechanize.urlopen(), but not mechanize.Browser()'s open() method:</p> <pre><code>diff --git a/mechanize/_opener.py b/mechanize/_opener.py index ad8412d..e6d1ebc 100644 --- a/mechanize/_opener.py +++ b/mechanize/_opener.py @@ -25,9 +25,27 @@ import _rfc3986 import _sockettimeout import _urllib2_fork from _util import isstringlike +import ssl, socket open_file = open +class HTTPSConnectionV3(httplib.HTTPSConnection): + def __init__(self, *args, **kwargs): + httplib.HTTPSConnection.__init__(self, *args, **kwargs) + + def connect(self): + sock = socket.create_connection((self.host, self.port), self.timeout) + if self._tunnel_host: + self.sock = sock + self._tunnel() + try: + self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_SSLv3) + except ssl.SSLError, e: + self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_SSLv23) + +class HTTPSHandlerV3(urllib2.HTTPSHandler): + def https_open(self, req): + return self.do_open(HTTPSConnectionV3, req) class ContentTooShortError(urllib2.URLError): def __init__(self, reason, result): @@ -370,7 +388,7 @@ class OpenerFactory: _urllib2_fork.HTTPErrorProcessor, ] if hasattr(httplib, 'HTTPS'): - default_classes.append(_urllib2_fork.HTTPSHandler) + default_classes.append(HTTPSHandlerV3) handlers = [] replacement_handlers = [] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload