add support for handlers when opening http urls (e.g., for authentication)
authorDov Feldstern <dovdevel@gmail.com>
Wed, 12 Feb 2014 00:35:13 +0000 (00:35 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 12 Feb 2014 00:35:13 +0000 (00:35 +0000)
dulwich/client.py

index 9b6b0470b2218a6d20cf7d3ee1f87948cbcb0a9f..1e10650c73a603b6444d5bead470a00309f8d8b9 100644 (file)
@@ -894,15 +894,18 @@ class SSHGitClient(TraditionalGitClient):
 
 class HttpGitClient(GitClient):
 
-    def __init__(self, base_url, dumb=None, *args, **kwargs):
+    def __init__(self, base_url, dumb=None, handlers=None, *args, **kwargs):
         self.base_url = base_url.rstrip("/") + "/"
         self.dumb = dumb
+        self.handlers = handlers or []
         GitClient.__init__(self, *args, **kwargs)
 
     def _get_url(self, path):
         return urlparse.urljoin(self.base_url, path).rstrip("/") + "/"
 
     def _http_request(self, url, headers={}, data=None):
+        opener = urllib2.build_opener(*self.handlers)
+        urllib2.install_opener(opener)
         req = urllib2.Request(url, headers=headers, data=data)
         try:
             resp = self._perform(req)