uaiohttpclient: Fix hard coded port 80.

Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
pull/764/head
Mark Blakeney 2023-11-08 08:11:39 +10:00 zatwierdzone przez Damien George
rodzic ae8ea8d113
commit 149226d3f7
2 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
metadata(description="HTTP client module for MicroPython uasyncio module", version="0.5.1")
metadata(description="HTTP client module for MicroPython uasyncio module", version="0.5.2")
# Originally written by Paul Sokolovsky.

Wyświetl plik

@ -46,9 +46,16 @@ def request_raw(method, url):
except ValueError:
proto, dummy, host = url.split("/", 2)
path = ""
if ":" in host:
host, port = host.split(":")
port = int(port)
else:
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.