[utils] YoutubeDLHTTPSHandler.https_open: pass all required arguments to do_open
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Thu, 29 Jan 2015 12:37:17 +0000 (13:37 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Thu, 29 Jan 2015 14:01:27 +0000 (15:01 +0100)
With this change the '--no-check-certificate' works again (#4807).

youtube_dl/utils.py

index b8c52af74768053d27b4642173022af3b2c6723d..a4c9813ecce0aa9ecef34ad4c3185ab2e75ce3ae 100644 (file)
@@ -654,9 +654,14 @@ class YoutubeDLHTTPSHandler(compat_urllib_request.HTTPSHandler):
         self._params = params
 
     def https_open(self, req):
+        kwargs = {}
+        if hasattr(self, '_context'):  # python > 2.6
+            kwargs['context'] = self._context
+        if hasattr(self, '_check_hostname'):  # python 3.x
+            kwargs['check_hostname'] = self._check_hostname
         return self.do_open(functools.partial(
             _create_http_connection, self, self._https_conn_class, True),
-            req)
+            req, **kwargs)
 
 
 def parse_iso8601(date_str, delimiter='T'):