Browse Source

Fix to urllib2_build_opener.build_opener to allow for custom handlers to be added correctly.

git-svn-id: http://proj.badc.rl.ac.uk/svn/ndg-security/trunk/ndg_httpsclient@8073 051b1e3e-aa0c-0410-b6c2-bfbade6052be
pjkersha 13 years ago
parent
commit
38d62e5c87
1 changed files with 5 additions and 2 deletions
  1. 5 2
      ndg/httpsclient/urllib2_build_opener.py

+ 5 - 2
ndg/httpsclient/urllib2_build_opener.py

@@ -18,7 +18,7 @@ log = logging.getLogger(__name__)
 
 
 # Copied from urllib2 with modifications for ssl
-def build_opener(ssl_context=None, *handlers):
+def build_opener(*handlers, **kw):
     """Create an opener object from a list of handlers.
 
     The opener will use several default handlers, including support
@@ -49,7 +49,10 @@ def build_opener(ssl_context=None, *handlers):
     for klass in default_classes:
         if klass not in skip:
             opener.add_handler(klass())
-
+            
+    # Pick up SSL context from keyword settings
+    ssl_context = kw.get('ssl_context')
+    
     # Add the HTTPS handler with ssl_context
     if HTTPSContextHandler not in skip:
         opener.add_handler(HTTPSContextHandler(ssl_context))