Skip to content

Commit 92f6520

Browse files
committed
fix socket bug, enable __del__ and __enter__, and switch poolmanager to use tuple of host, port, and scheme
1 parent b93d808 commit 92f6520

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lightbug_http/client.mojo

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ fn parse_host_and_port(source: String, is_tls: Bool) raises -> (String, UInt16):
2020
Returns:
2121
A tuple containing the host and port.
2222
"""
23-
var port: UInt16
2423
if source.count(":") != 1:
25-
port = 443 if is_tls else 80
24+
var port: UInt16 = 443 if is_tls else 80
2625
return source, port
2726

28-
var host: String
29-
var reader = ByteReader(source.as_bytes())
30-
host = StringSlice(unsafe_from_utf8=reader.read_until(ord(":")))
31-
port = atol(StringSlice(unsafe_from_utf8=reader.read_bytes()[1:]))
32-
return host^, port
27+
var result = source.split(":")
28+
return result[0], UInt16(atol(result[1]))
3329

3430

3531
struct Client:

0 commit comments

Comments
 (0)