Commits

benoitc  committed 75ea3d1

fix proxy_auth import

  • Participants
  • Parent commits 32262fe

Comments (0)

Files changed (3)

File restkit/httpc.py

 
 import restkit
 from restkit import errors
-from restkit.pool import ConnectionPool
+from restkit.pool import ConnectionPool, get_proxy_auth
 from restkit.utils import to_bytestring
 
 
             headers.setdefault("Content-Length", str(len(body)))
             
         if self.use_proxy and uri.scheme != "https":
-            proxy_auth = _get_proxy_auth()
+            proxy_auth = get_proxy_auth()
             if proxy_auth:
                 headers['Proxy-Authorization'] = proxy_auth.strip()
             
         if binarydata == '': break
         connection.send(binarydata)
         
-def _get_proxy_auth():
-  import base64
-  proxy_username = os.environ.get('proxy-username')
-  if not proxy_username:
-    proxy_username = os.environ.get('proxy_username')
-  proxy_password = os.environ.get('proxy-password')
-  if not proxy_password:
-    proxy_password = os.environ.get('proxy_password')
-  if proxy_username:
-    user_auth = base64.b64encode('%s:%s' % (proxy_username,
-                                            proxy_password))
-    return 'Basic %s\r\n' % (user_auth.strip())
-  else:
-    return ''
         
 class ResponseStream(object):
     

File restkit/pool.py

 
 from restkit import errors
 
+def get_proxy_auth():
+  import base64
+  proxy_username = os.environ.get('proxy-username')
+  if not proxy_username:
+    proxy_username = os.environ.get('proxy_username')
+  proxy_password = os.environ.get('proxy-password')
+  if not proxy_password:
+    proxy_password = os.environ.get('proxy_password')
+  if proxy_username:
+    user_auth = base64.b64encode('%s:%s' % (proxy_username,
+                                            proxy_password))
+    return 'Basic %s\r\n' % (user_auth.strip())
+  else:
+    return ''
+
 def make_proxy_connection(uri):
     headers = headers or {}
     proxy = None
         return make_connection(uri, use_proxy=False)
   
     if uri.scheme == 'https':
-        proxy_auth = _get_proxy_auth()
+        proxy_auth = get_proxy_auth()
         if proxy_auth:
             proxy_auth = 'Proxy-authorization: %s' % proxy_auth
         port = uri.port

File restkit/rest.py

 
     """
     def __init__(self, uri, transport=None, headers=None, follow_redirect=True, 
-        force_follow_redirect=False, use_proxy=False, min_size=0, max_size=4, pool_class=None):
+            force_follow_redirect=False, use_proxy=False, min_size=0, 
+            max_size=4, pool_class=None):
         """Constructor for a `Resource` object.
 
         Resource represent an HTTP resource.