aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-09 01:12:06 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-09 01:12:35 -0800
commitd90a638101921807d6dc8fca14fc39f843552983 (patch)
tree518407ecd84e722ee166192602c8bc3998517d09 /src
parent047a8d3f0d39118ded97f693d4e4a7cb23e8c6a4 (diff)
downloadbun-d90a638101921807d6dc8fca14fc39f843552983.tar.gz
bun-d90a638101921807d6dc8fca14fc39f843552983.tar.zst
bun-d90a638101921807d6dc8fca14fc39f843552983.zip
Re-enable workaround for 127.0.0.01
Diffstat (limited to 'src')
-rw-r--r--src/feature_flags.zig2
-rw-r--r--src/http/websocket_http_client.zig13
-rw-r--r--src/http_client_async.zig10
3 files changed, 17 insertions, 8 deletions
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index c3a9fea10..3d016efb6 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -104,4 +104,4 @@ pub const disable_lolhtml = false;
/// on macOS that specifically impacts localhost and not
/// other ipv4 hosts. This is a workaround for that.
/// "localhost" fails to connect.
-pub const hardcode_localhost_to_127_0_0_1 = env.isMac;
+pub const hardcode_localhost_to_127_0_0_1 = true;
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig
index f0cdc2e54..494fff484 100644
--- a/src/http/websocket_http_client.zig
+++ b/src/http/websocket_http_client.zig
@@ -193,8 +193,17 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type {
client.poll_ref.ref(vm);
if (Socket.connect(host_.slice(), port, @ptrCast(*uws.SocketContext, socket_ctx), HTTPClient, client, "tcp")) |out| {
if (comptime ssl) {
- if (!strings.isIPAddress(host_.slice())) {
- out.hostname = bun.default_allocator.dupeZ(u8, host_.slice()) catch "";
+ 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 "";
}
}
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index c49979e7f..9f2b9a163 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -301,11 +301,11 @@ fn NewHTTPContext(comptime ssl: bool) type {
return null;
}
- pub fn connect(this: *@This(), client: *HTTPClient, hostname: []const u8, port: u16) !HTTPSocket {
- // const hostname = if (FeatureFlags.hardcode_localhost_to_127_0_0_1 and strings.eqlComptime(hostname_, "localhost"))
- // "127.0.0.1"
- // else
- // hostname_;
+ pub fn connect(this: *@This(), client: *HTTPClient, hostname_: []const u8, port: u16) !HTTPSocket {
+ const hostname = if (FeatureFlags.hardcode_localhost_to_127_0_0_1 and strings.eqlComptime(hostname_, "localhost"))
+ "127.0.0.1"
+ else
+ hostname_;
client.connected_url = client.url;
client.connected_url.hostname = hostname;