Skip to content

Commit e9c3d04

Browse files
committed
uaiohttpclient: Allow non-standard port number
1 parent f20d89c commit e9c3d04

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

uaiohttpclient/uaiohttpclient.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,17 @@ def request_raw(method, url):
4848
except ValueError:
4949
proto, dummy, host = url.split("/", 2)
5050
path = ""
51+
52+
host_port = host.rsplit("@", 1)[-1]
53+
try:
54+
host, port = host_port.rsplit(":", 1)[-1]
55+
except ValueError:
56+
host = host_port
57+
port = 80
58+
5159
if proto != "http:":
5260
raise ValueError("Unsupported protocol: " + proto)
53-
reader, writer = yield from asyncio.open_connection(host, 80)
61+
reader, writer = yield from asyncio.open_connection(host, port)
5462
# Use protocol 1.0, because 1.1 always allows to use chunked transfer-encoding
5563
# But explicitly set Connection: close, even though this should be default for 1.0,
5664
# because some servers misbehave w/o it.

0 commit comments

Comments
 (0)