Skip to content

Commit

Permalink
Merge branch 'main' into cdp_struct
Browse files Browse the repository at this point in the history
  • Loading branch information
karlseguin committed Feb 13, 2025
2 parents 1846d0b + d8fae5b commit a43a6a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const AcceptError = jsruntime.IO.AcceptError;
const RecvError = jsruntime.IO.RecvError;
const SendError = jsruntime.IO.SendError;
const CloseError = jsruntime.IO.CloseError;
const CancelError = jsruntime.IO.CancelError;
const CancelError = jsruntime.IO.CancelOneError;
const TimeoutError = jsruntime.IO.TimeoutError;

const CDP = @import("cdp/cdp.zig").CDP;
Expand All @@ -47,6 +47,7 @@ const MAX_HTTP_REQUEST_SIZE = 2048;
// +140 for the max control packet that might be interleaved in a message
const MAX_MESSAGE_SIZE = 256 * 1024 + 14;


pub const Client = ClientT(*Server, CDP);

const Server = struct {
Expand Down Expand Up @@ -242,8 +243,7 @@ const Server = struct {
// (with its own completion), allocated on the heap.
// After the send (on the sendCbk) the dedicated context will be destroy
// and the data slice will be free.
const Send = struct {
// Any unsent data we have.
const Send = struct { // Any unsent data we have.
unsent: []const u8,

server: *Server,
Expand Down Expand Up @@ -307,7 +307,6 @@ fn ClientT(comptime S: type, comptime C: type) type {
const CLOSE_NORMAL = [_]u8{ 136, 2, 3, 232 }; // code: 1000
const CLOSE_TOO_BIG = [_]u8{ 136, 2, 3, 241 }; // 1009
const CLOSE_PROTOCOL_ERROR = [_]u8{ 136, 2, 3, 234 }; //code: 1002

// "private-use" close codes must be from 4000-49999
const CLOSE_TIMEOUT = [_]u8{ 136, 2, 15, 160 }; // code: 4000

Expand Down Expand Up @@ -521,8 +520,8 @@ fn ClientT(comptime S: type, comptime C: type) type {

// The response will be sent via the IO Loop and thus has to have its
// own lifetime.

const res = try arena.allocator().dupe(u8, template);

// magic response
const key_pos = res.len - 32;
var h: [20]u8 = undefined;
Expand Down Expand Up @@ -1223,6 +1222,7 @@ test "Client: write websocket message" {
.{ .expected = &.{ 129, 2, '"', '"' }, .message = "" },
.{ .expected = [_]u8{ 129, 14 } ++ "\"hello world!\"", .message = "hello world!" },
.{ .expected = [_]u8{ 129, 126, 0, 132 } ++ "\"" ++ ("A" ** 130) ++ "\"", .message = "A" ** 130 },

};

for (cases) |c| {
Expand All @@ -1233,7 +1233,6 @@ test "Client: write websocket message" {
defer client.deinit();

try client.sendJSON(c.message, .{});

try testing.expectEqual(1, ms.sent.items.len);
try testing.expectEqualSlices(u8, c.expected, ms.sent.items[0]);
}
Expand Down
1 change: 1 addition & 0 deletions src/unit_tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,6 @@ test {
std.testing.refAllDecls(@import("generate.zig"));
std.testing.refAllDecls(@import("http/Client.zig"));
std.testing.refAllDecls(@import("storage/storage.zig"));
std.testing.refAllDecls(@import("iterator/iterator.zig"));
std.testing.refAllDecls(@import("server.zig"));
}
2 changes: 1 addition & 1 deletion vendor/zig-js-runtime

0 comments on commit a43a6a2

Please sign in to comment.