diff options
author | 2022-11-09 01:15:36 -0800 | |
---|---|---|
committer | 2022-11-09 01:15:36 -0800 | |
commit | fac1c49727ec76387ada0ad2e4bfa32385b4ceb1 (patch) | |
tree | 1db49950b1caf61393cd3d8b1e22d5698840a19e | |
parent | 3a760ec0ece6e103733e1e41b7de8623997a56f6 (diff) | |
download | bun-fac1c49727ec76387ada0ad2e4bfa32385b4ceb1.tar.gz bun-fac1c49727ec76387ada0ad2e4bfa32385b4ceb1.tar.zst bun-fac1c49727ec76387ada0ad2e4bfa32385b4ceb1.zip |
Fixup
-rw-r--r-- | src/http/websocket_http_client.zig | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index 494fff484..66592ea34 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -191,19 +191,23 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { const prev_start_server_on_next_tick = vm.eventLoop().start_server_on_next_tick; vm.eventLoop().start_server_on_next_tick = true; client.poll_ref.ref(vm); - if (Socket.connect(host_.slice(), port, @ptrCast(*uws.SocketContext, socket_ctx), HTTPClient, client, "tcp")) |out| { + const display_host_ = host_.slice(); + const display_host = if (bun.FeatureFlags.hardcode_localhost_to_127_0_0_1 and strings.eqlComptime(display_host_, "localhost")) + "127.0.0.1" + else + display_host_; + + if (Socket.connect( + display_host, + port, + @ptrCast(*uws.SocketContext, socket_ctx), + HTTPClient, + client, + "tcp", + )) |out| { if (comptime ssl) { - const display_host = host_.slice(); - if (!strings.isIPAddress(display_host)) { - const hostname = if (FeatureFlags.hardcode_localhost_to_127_0_0_1 and strings.eqlComptime(display_host, "localhost")) - "127.0.0.1" - else - display_host; - - out.hostname = bun.default_allocator.dupeZ( - u8, - hostname, - ) catch ""; + if (!strings.isIPAddress(host_.slice())) { + out.hostname = bun.default_allocator.dupeZ(u8, host_.slice()) catch ""; } } |