diff options
Diffstat (limited to 'src/http/websocket_http_client.zig')
-rw-r--r-- | src/http/websocket_http_client.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index 89c3f70c8..6a62ceb87 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -191,6 +191,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { pub const onTimeout = handleTimeout; pub const onConnectError = handleConnectError; pub const onEnd = handleEnd; + pub const onHandshake = handleHandshake; }, ); if (is_new_loop) { @@ -287,12 +288,14 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { } pub fn fail(this: *HTTPClient, code: ErrorCode) void { + log("onFail", .{}); JSC.markBinding(@src()); WebSocket__didCloseWithErrorCode(this.outgoing_websocket, code); this.cancel(); } pub fn handleClose(this: *HTTPClient, _: Socket, _: c_int, _: ?*anyopaque) void { + log("onClose", .{}); JSC.markBinding(@src()); this.clearData(); WebSocket__didCloseWithErrorCode(this.outgoing_websocket, ErrorCode.ended); @@ -304,6 +307,15 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.tcp.close(0, null); } + pub fn handleHandshake(this: *HTTPClient, socket: Socket, success: i32, ssl_error: uws.us_bun_verify_error_t) void { + _ = socket; + _ = ssl_error; + log("onHandshake({d})", .{success}); + if (success == 0) { + this.fail(ErrorCode.failed_to_connect); + } + } + pub fn handleOpen(this: *HTTPClient, socket: Socket) void { log("onOpen", .{}); std.debug.assert(socket.socket == this.tcp.socket); @@ -861,6 +873,8 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { pub const onTimeout = handleTimeout; pub const onConnectError = handleConnectError; pub const onEnd = handleEnd; + // just by adding it will fix ssl handshake + pub const onHandshake = handleHandshake; }, ); } @@ -894,7 +908,18 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { this.cancel(); } + pub fn handleHandshake(this: *WebSocket, socket: Socket, success: i32, ssl_error: uws.us_bun_verify_error_t) void { + _ = socket; + _ = ssl_error; + log("WebSocket.onHandshake({d})", .{success}); + if (success == 0) { + if (this.outgoing_websocket) |ws| { + WebSocket__didCloseWithErrorCode(ws, ErrorCode.failed_to_connect); + } + } + } pub fn handleClose(this: *WebSocket, _: Socket, _: c_int, _: ?*anyopaque) void { + log("onClose", .{}); JSC.markBinding(@src()); this.clearData(); if (this.outgoing_websocket) |ws| |