Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Change http11 and http20 constructors to use new utility function for…
… host and proxy
  • Loading branch information
fredthomsen committed Oct 16, 2015
commit 4ec8b836a26ef8de3d57d2c5c6f1f4213dfa2cc0
13 changes: 2 additions & 11 deletions hyper/http11/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ class HTTP11Connection(object):
def __init__(self, host, port=None, secure=None, ssl_context=None,
proxy_host=None, proxy_port=None, **kwargs):
if port is None:
try:
self.host, self.port = host.split(':')
self.port = int(self.port)
except ValueError:
self.host, self.port = host, 80
self.host, self.port = to_host_port_tuple(host)
Copy link
Member

Choose a reason for hiding this comment

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

Let's be explicit about the default port here too.

else:
self.host, self.port = host, port

Expand All @@ -83,12 +79,7 @@ def __init__(self, host, port=None, secure=None, ssl_context=None,
# Setup proxy details if applicable.
if proxy_host:
if proxy_port is None:
try:
self.proxy_host, self.proxy_port = proxy_host.split(':')
except ValueError:
self.proxy_host, self.proxy_port = proxy_host, 8080
else:
self.proxy_port = int(self.proxy_port)
self.proxy_host, self.proxy_port = to_host_port_tuple(proxy_host, default_port=8080)
else:
self.proxy_host, self.proxy_port = proxy_host, proxy_port
else:
Expand Down
13 changes: 2 additions & 11 deletions hyper/http20/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ def __init__(self, host, port=None, secure=None, window_manager=None, enable_pus
Creates an HTTP/2 connection to a specific server.
"""
if port is None:
try:
self.host, self.port = host.split(':')
self.port = int(self.port)
except ValueError:
self.host, self.port = host, 443
self.host, self.port = to_host_port_tuple(host)
else:
self.host, self.port = host, port

Expand All @@ -88,12 +84,7 @@ def __init__(self, host, port=None, secure=None, window_manager=None, enable_pus
# Setup proxy details if applicable.
if proxy_host:
if proxy_port is None:
try:
self.proxy_host, self.proxy_port = proxy_host.split(':')
except ValueError:
self.proxy_host, self.proxy_port = proxy_host, 8080
else:
self.proxy_port = int(self.proxy_port)
self.proxy_host, self.proxy_port = to_host_port_tuple(proxy_host, default_port=8080)
else:
self.proxy_host, self.proxy_port = proxy_host, proxy_port
else:
Expand Down