diff options
author | awachtler <axel@uracoli.de> | 2020-10-06 22:19:05 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-10-20 12:44:30 +1100 |
commit | 56e0932485af51ec175c8f43432eee67d657b334 (patch) | |
tree | 803a78b5843503b669e655105468dc2c4453a66c | |
parent | 18518e26a7a92345fdcf8ad79e4c8b3a753f2d06 (diff) |
tools/upip.py: Support explicit port number in host.
Adding a port number other then 443 to a PyPI URL may be needed if a local
server like devpi is used.
-rw-r--r-- | tools/upip.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/upip.py b/tools/upip.py index 0036eac25..aa8aecedf 100644 --- a/tools/upip.py +++ b/tools/upip.py @@ -129,7 +129,11 @@ def url_open(url): proto, _, host, urlpath = url.split("/", 3) try: - ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM) + port = 443 + if ":" in host: + host, port = host.split(":") + port = int(port) + ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM) except OSError as e: fatal("Unable to resolve %s (no Internet?)" % host, e) # print("Address infos:", ai) @@ -147,7 +151,7 @@ def url_open(url): warn_ussl = False # MicroPython rawsocket module supports file interface directly - s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host)) + s.write("GET /%s HTTP/1.0\r\nHost: %s:%s\r\n\r\n" % (urlpath, host, port)) l = s.readline() protover, status, msg = l.split(None, 2) if status != b"200": |