diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 95f9655b18..580f9e0846 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -3340,7 +3340,7 @@ fn NewSocket(comptime ssl: bool) type { if (servername == null) { return JSValue.jsUndefined(); } - return ZigString.fromUTF8(servername[0..bun.len(servername)]).toJS(globalObject); + return bun.String.createUTF8ForJS(globalObject, servername[0..bun.len(servername)]); } pub fn setServername( this: *This, diff --git a/src/js/node/http2.ts b/src/js/node/http2.ts index af9d310b21..5b99aaac8b 100644 --- a/src/js/node/http2.ts +++ b/src/js/node/http2.ts @@ -2299,7 +2299,7 @@ function initOriginSet(session: Http2Session) { } } let originString = `https://${hostName}`; - if (socket.remotePort != null) originString += `:${socket.remotePort}`; + if (socket.remotePort != null && socket.remotePort != 443) originString += `:${socket.remotePort}`; originSet.add(originString); } return originSet; diff --git a/test/js/third_party/got/got.http2-wrapper.test.ts b/test/js/third_party/got/got.http2-wrapper.test.ts index cd5f4ab86e..36ca07920a 100644 --- a/test/js/third_party/got/got.http2-wrapper.test.ts +++ b/test/js/third_party/got/got.http2-wrapper.test.ts @@ -4,6 +4,13 @@ import { tls } from "harness"; import http2 from "http2"; import { once } from "events"; +test("can make http2 request using servername", async () => { + // actually using a servername + const response = await got("https://example.com", { + http2: true, + }); + expect(response.statusCode).toBe(200); +}); test("can make http2 request to local http2 server", async () => { const server = http2.createSecureServer(tls);