Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions libcloud/httplib_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ class LibcloudConnection(LibcloudBaseConnection):
response = None

def __init__(self, host, port, **kwargs):
self.host = '{0}://{1}'.format(
self.host = '{0}://{1}{2}'.format(
'https' if port == 443 else 'http',
Copy link
Copy Markdown
Member

@Kami Kami Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have access to secure argument here?

Because if we do, it looks like we still don't correctly handle one scenario - https on a non default port (protocol is not set correctly). For example, secure=True, port=8080 should result in https://<host>:8080.

Or am I missing something?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: Sorry, I should have read the description better - you already addressed this scenario there.

Also checked the code and it looks like "secure" argument is not passed to the constructor right now so yeah, we would need to change some code to make it work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kami yes, absolutely. That's a separate PR. I'm back to making one change at a time!

host
host,
":{0}".format(port) if port not in (80, 443) else ""
)
# Support for HTTP proxy
proxy_url_env = os.environ.get(HTTP_PROXY_ENV_VARIABLE_NAME, None)
Expand Down
10 changes: 10 additions & 0 deletions libcloud/test/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ def test_constructor(self):
self.assertEqual(conn.proxy_host, '127.0.0.5')
self.assertEqual(conn.proxy_port, 3128)

def test_connection_to_unusual_port(self):
conn = LibcloudConnection(host='localhost', port=8080)
self.assertEqual(conn.proxy_scheme, None)
self.assertEqual(conn.proxy_host, None)
self.assertEqual(conn.proxy_port, None)
self.assertEqual(conn.host, 'http://localhost:8080')

conn = LibcloudConnection(host='localhost', port=80)
self.assertEqual(conn.host, 'http://localhost')


class ConnectionClassTestCase(unittest.TestCase):
def setUp(self):
Expand Down