Skip to content

Commit c3e206c

Browse files
committed
cdp: use enum for AuthChallengeResponse
1 parent fd13e2a commit c3e206c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cdp/domains/fetch.zig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,19 @@ fn continueRequest(cmd: anytype) !void {
274274
return cmd.sendResult(null, .{});
275275
}
276276

277+
// https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#type-AuthChallengeResponse
278+
const AuthChallengeResponse = enum {
279+
Default,
280+
CancelAuth,
281+
ProvideCredentials,
282+
};
283+
277284
fn continueWithAuth(cmd: anytype) !void {
278285
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
279286
const params = (try cmd.params(struct {
280287
requestId: []const u8, // "INTERCEPT-{d}"
281288
authChallengeResponse: struct {
282-
response: []const u8,
289+
response: AuthChallengeResponse,
283290
username: []const u8 = "",
284291
password: []const u8 = "",
285292
},
@@ -297,7 +304,7 @@ fn continueWithAuth(cmd: anytype) !void {
297304
.response = params.authChallengeResponse.response,
298305
});
299306

300-
if (!std.mem.eql(u8, params.authChallengeResponse.response, "ProvideCredentials")) {
307+
if (params.authChallengeResponse.response != .ProvideCredentials) {
301308
transfer.abortAuthChallenge();
302309
return cmd.sendResult(null, .{});
303310
}

0 commit comments

Comments
 (0)