Skip to content

uaiohttpclient: Allow non-standard port number #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion uaiohttpclient/uaiohttpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ def request_raw(method, url):
except ValueError:
proto, dummy, host = url.split("/", 2)
path = ""

host_port = host.rsplit("@", 1)[-1]
try:
host, port = host_port.rsplit(":", 1)
except ValueError:
host = host_port
port = 80

if proto != "http:":
raise ValueError("Unsupported protocol: " + proto)
reader, writer = yield from asyncio.open_connection(host, 80)
reader, writer = yield from asyncio.open_connection(host, port)
# Use protocol 1.0, because 1.1 always allows to use chunked transfer-encoding
# But explicitly set Connection: close, even though this should be default for 1.0,
# because some servers misbehave w/o it.
Expand Down