From e9c3d0491abbc69d6b9f5f8b2540b38abb53bcfd Mon Sep 17 00:00:00 2001 From: Raymond Tau Date: Thu, 21 Jun 2018 02:09:37 +0800 Subject: [PATCH 1/2] uaiohttpclient: Allow non-standard port number --- uaiohttpclient/uaiohttpclient.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/uaiohttpclient/uaiohttpclient.py b/uaiohttpclient/uaiohttpclient.py index cf7fe19eb..4a79065e2 100644 --- a/uaiohttpclient/uaiohttpclient.py +++ b/uaiohttpclient/uaiohttpclient.py @@ -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)[-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. From 670cfdfb129b4df69da79aab084b1382c2d508d5 Mon Sep 17 00:00:00 2001 From: Raymond Tau Date: Tue, 3 Jul 2018 02:17:24 +0800 Subject: [PATCH 2/2] Update uaiohttpclient.py --- uaiohttpclient/uaiohttpclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uaiohttpclient/uaiohttpclient.py b/uaiohttpclient/uaiohttpclient.py index 4a79065e2..fbc3a9dce 100644 --- a/uaiohttpclient/uaiohttpclient.py +++ b/uaiohttpclient/uaiohttpclient.py @@ -51,7 +51,7 @@ def request_raw(method, url): host_port = host.rsplit("@", 1)[-1] try: - host, port = host_port.rsplit(":", 1)[-1] + host, port = host_port.rsplit(":", 1) except ValueError: host = host_port port = 80