Skip to content

Commit 3690354

Browse files
committed
fix scheme parsing bug and remove constants
1 parent fc9b238 commit 3690354

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lightbug_http/client.mojo

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ struct Client:
6262
is_tls = True
6363
scheme = Scheme.HTTPS
6464

65-
port = request.uri.port.value() if request.uri.port else 80
65+
var port: UInt16
66+
if request.uri.port:
67+
port = request.uri.port.value()
68+
else:
69+
if request.uri.scheme == Scheme.HTTP.value:
70+
port = 80
71+
elif request.uri.scheme == Scheme.HTTPS.value:
72+
port = 443
73+
else:
74+
raise Error("Client.do: Invalid scheme received in the URI.")
75+
6676
var pool_key = PoolKey(request.uri.host, port, scheme)
6777
var cached_connection = False
6878
var conn: TCPConnection

0 commit comments

Comments
 (0)