Skip to content

Commit dbb295c

Browse files
committed
fix the request breaking without port
1 parent afd0793 commit dbb295c

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lightbug_http/sys/client.mojo

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,19 @@ struct MojoClient(Client):
7474
if uri.is_https():
7575
is_tls = True
7676

77-
var host_port = host.split(":")
78-
var host_str = host_port[0]
79-
var port = atol(host_port[1])
77+
var host_str: String
78+
var port: Int
79+
80+
if host.__contains__(":"):
81+
var host_port = host.split(":")
82+
host_str = host_port[0]
83+
port = atol(host_port[1])
84+
else:
85+
host_str = host
86+
if is_tls:
87+
port = 443
88+
else:
89+
port = 80
8090

8191
var conn = create_connection(self.fd, host_str, port)
8292

lightbug_http/tests/test_client.mojo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ from lightbug_http.tests.utils import (
1010
getRequest,
1111
)
1212

13+
1314
fn test_mojo_client_lightbug(client: MojoClient) raises:
1415
var res = client.do(
1516
HTTPRequest(
@@ -26,6 +27,7 @@ fn test_mojo_client_lightbug(client: MojoClient) raises:
2627
),
2728
)
2829

30+
2931
fn test_python_client_lightbug(client: PythonClient) raises:
3032
var res = client.do(
3133
HTTPRequest(

0 commit comments

Comments
 (0)