You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/08/21 18:14:31 UTC
[1/2] git commit: Add missing "set_http_proxy" method to the base
Connection class
Repository: libcloud
Updated Branches:
refs/heads/trunk 06707ef0c -> bef5399b5
Add missing "set_http_proxy" method to the base Connection class
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a3a09590
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a3a09590
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a3a09590
Branch: refs/heads/trunk
Commit: a3a0959001d63e90a97bcc04916ec7e68fe44e43
Parents: 06707ef
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Aug 21 18:00:24 2014 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 21 18:00:24 2014 +0200
----------------------------------------------------------------------
libcloud/common/base.py | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/a3a09590/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 07647b2..78a9a13 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -483,6 +483,15 @@ class Connection(object):
self.proxy_url = proxy_url
+ def set_http_proxy(self, proxy_url):
+ """
+ Set an HTTP proxy which will be used for all the outgoing HTTP requests.
+
+ :param proxy_url: Proxy URL.
+ :type proxy_url: ``str``
+ """
+ self.proxy_url = proxy_url
+
def set_context(self, context):
if not isinstance(context, dict):
raise TypeError('context needs to be a dictionary')
[2/2] git commit: Improve URL validation, update docstring.
Posted by to...@apache.org.
Improve URL validation, update docstring.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/bef5399b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/bef5399b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/bef5399b
Branch: refs/heads/trunk
Commit: bef5399b5bb9b539c40c3770ae28546468c6b6cc
Parents: a3a0959
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Aug 21 18:02:25 2014 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 21 18:05:33 2014 +0200
----------------------------------------------------------------------
libcloud/common/base.py | 7 +++++--
libcloud/httplib_ssl.py | 2 +-
libcloud/test/test_connection.py | 12 ++++++++++++
3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bef5399b/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index 78a9a13..f559c22 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -485,9 +485,12 @@ class Connection(object):
def set_http_proxy(self, proxy_url):
"""
- Set an HTTP proxy which will be used for all the outgoing HTTP requests.
+ Set a HTTP proxy which will be used with this connection.
- :param proxy_url: Proxy URL.
+ :param proxy_url: Proxy URL (e.g. http://<hostname>:<port> without
+ authentication and
+ http://<username>:<password>@<hostname>:<port> for
+ basic auth authentication information.
:type proxy_url: ``str``
"""
self.proxy_url = proxy_url
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bef5399b/libcloud/httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/httplib_ssl.py b/libcloud/httplib_ssl.py
index 4497da3..104bf34 100644
--- a/libcloud/httplib_ssl.py
+++ b/libcloud/httplib_ssl.py
@@ -107,7 +107,7 @@ class LibcloudBaseConnection(object):
username_password = netloc.split('@', 1)[0]
split = username_password.split(':', 1)
- if len(split) == 0:
+ if len(split) < 2:
raise ValueError('URL is in an invalid format')
proxy_username, proxy_password = split[0], split[1]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/bef5399b/libcloud/test/test_connection.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_connection.py b/libcloud/test/test_connection.py
index c97cfb4..821425d 100644
--- a/libcloud/test/test_connection.py
+++ b/libcloud/test/test_connection.py
@@ -59,6 +59,18 @@ class BaseConnectionClassTestCase(unittest.TestCase):
conn._parse_proxy_url,
proxy_url=proxy_url)
+ proxy_url = 'http://@127.0.0.1:3128'
+ expected_msg = 'URL is in an invalid format'
+ self.assertRaisesRegexp(ValueError, expected_msg,
+ conn._parse_proxy_url,
+ proxy_url=proxy_url)
+
+ proxy_url = 'http://user@127.0.0.1:3128'
+ expected_msg = 'URL is in an invalid format'
+ self.assertRaisesRegexp(ValueError, expected_msg,
+ conn._parse_proxy_url,
+ proxy_url=proxy_url)
+
def test_constructor(self):
conn = LibcloudHTTPConnection(host='localhost', port=80)
self.assertEqual(conn.proxy_scheme, None)