@@ -115,8 +115,8 @@ fn disable(cmd: anytype) !void {
115115
116116fn enable (cmd : anytype ) ! void {
117117 const params = (try cmd .params (EnableParam )) orelse EnableParam {};
118- if (params .patterns .len != 0 ) std . debug . print ( "Fetch.enable: Not implemented patterns set \n " , .{});
119- if (params .handleAuthRequests ) std . debug . print ( "Fetch.enable: Not implemented handleAuthRequests set \n " , .{});
118+ if (params .patterns .len != 0 ) log . warn ( .cdp , "Fetch.enable No patterns yet " , .{});
119+ if (params .handleAuthRequests ) log . warn ( .cdp , "Fetch.enable No auth yet " , .{});
120120
121121 const bc = cmd .browser_context orelse return error .BrowserContextNotLoaded ;
122122 try bc .fetchEnable ();
@@ -170,7 +170,7 @@ pub fn requestPaused(arena: Allocator, bc: anytype, intercept: *const Notificati
170170 .networkId = try std .fmt .allocPrint (arena , "REQ-{d}" , .{intercept .request .id .? }),
171171 }, .{ .session_id = session_id });
172172
173- // TODO await either continueRequest, failRequest or fulfillRequest
173+ // Await either continueRequest, failRequest or fulfillRequest
174174 intercept .wait_for_interception .* = true ;
175175}
176176
@@ -191,7 +191,7 @@ fn continueRequest(cmd: anytype) !void {
191191 })) orelse return error .InvalidParams ;
192192 if (params .postData != null or params .headers != null or params .interceptResponse ) return error .NotYetImplementedParams ;
193193
194- const request_id = try id_from_request_id (params .requestId );
194+ const request_id = try idFromRequestId (params .requestId );
195195 var waiting_request = (bc .cdp .intercept_state .waiting .fetchSwapRemove (request_id ) orelse return error .RequestNotFound ).value ;
196196
197197 // Update the request with the new parameters
@@ -203,7 +203,7 @@ fn continueRequest(cmd: anytype) !void {
203203 waiting_request .method = std .meta .stringToEnum (Method , method ) orelse return error .InvalidParams ;
204204 }
205205
206- log .info (.cdp , "Request continued by intercept" , .{params .requestId });
206+ log .info (.cdp , "Request continued by intercept" , .{ . id = params .requestId });
207207 try bc .cdp .browser .http_client .request (waiting_request );
208208
209209 return cmd .sendResult (null , .{});
@@ -217,17 +217,15 @@ fn failRequest(cmd: anytype) !void {
217217 errorReason : ErrorReason ,
218218 })) orelse return error .InvalidParams ;
219219
220- const request_id = try id_from_request_id (params .requestId );
220+ const request_id = try idFromRequestId (params .requestId );
221221 if (state .waiting .fetchSwapRemove (request_id ) == null ) return error .RequestNotFound ;
222222
223- log .info (.cdp , "Request aborted by intercept" , .{params .errorReason });
223+ log .info (.cdp , "Request aborted by intercept" , .{ . reason = params .errorReason });
224224 return cmd .sendResult (null , .{});
225225}
226226
227227// Get u64 from requestId which is formatted as: "INTERCEPT-{d}"
228- fn id_from_request_id (request_id : []const u8 ) ! u64 {
229- return std .fmt .parseInt (u64 , request_id [10.. ], 10 ) catch | err | {
230- log .err (.cdp , "Failed to parse requestId" , .{request_id });
231- return err ;
232- };
228+ fn idFromRequestId (request_id : []const u8 ) ! u64 {
229+ if (! std .mem .startsWith (u8 , request_id , "INTERCEPT-" )) return error .InvalidParams ;
230+ return std .fmt .parseInt (u64 , request_id [10.. ], 10 ) catch return error .InvalidParams ;
233231}
0 commit comments