Skip to content

Commit ea19f7e

Browse files
committed
server: implement /json/list
Mimic Chrome's endpoints to enable Selenium CDP connection.
1 parent d8fae5b commit ea19f7e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/server.zig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,16 @@ fn Client(comptime S: type) type {
578578
return self.send(self.server.json_version_response, false);
579579
}
580580

581+
const json_list_response =
582+
"HTTP/1.1 200 OK\r\n" ++
583+
"Content-Length: 47\r\n" ++
584+
"Content-Type: application/json; charset=UTF-8\r\n\r\n" ++
585+
"[{\"id\":\"1\",\"type\":\"page\",\"url\":\"abount:blank\"}]";
586+
587+
if (std.mem.eql(u8, url, "/json/list")) {
588+
return self.send(json_list_response, false);
589+
}
590+
581591
return error.NotFound;
582592
}
583593

@@ -1123,12 +1133,12 @@ pub fn run(
11231133

11241134
// Utils
11251135
// --------
1126-
1136+
//
11271137
fn buildJSONVersionResponse(
11281138
allocator: Allocator,
11291139
address: net.Address,
11301140
) ![]const u8 {
1131-
const body_format = "{{\"webSocketDebuggerUrl\": \"ws://{}/\"}}";
1141+
const body_format = "{{\"Browser\": \"Chrome/132.0.6834.110\", \"WebKit-Version\": \"537.36 (@df453a35f099772fdb954e33551388add2ca3cde)\", \"webSocketDebuggerUrl\": \"ws://{}/\"}}";
11321142
const body_len = std.fmt.count(body_format, .{address});
11331143

11341144
const response_format =

0 commit comments

Comments
 (0)