Skip to content

Commit b98edf3

Browse files
committed
CDP response statusText
1 parent 02fe46d commit b98edf3

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/cdp/domains/network.zig

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ pub fn httpRequestComplete(arena: Allocator, bc: anytype, request: *const Notifi
316316
.response = .{
317317
.url = url,
318318
.status = request.status,
319+
.statusText = statusText(request.status),
319320
.headers = std.json.ArrayHashMap([]const u8){ .map = headers },
320321
},
321322
.frameId = target_id,
@@ -328,6 +329,79 @@ fn urlToString(arena: Allocator, url: *const std.Uri, opts: std.Uri.WriteToStrea
328329
return buf.items;
329330
}
330331

332+
fn statusText(status: u16) []const u8 {
333+
switch (status) {
334+
100 => return "Continue",
335+
101 => return "Switching Protocols",
336+
102 => return "Processing",
337+
103 => return "Early Hints",
338+
339+
200 => return "OK",
340+
201 => return "Created",
341+
202 => return "Accepted",
342+
203 => return "Non-Authoritative Information",
343+
204 => return "No Content",
344+
205 => return "Reset Content",
345+
206 => return "Partial Content",
346+
207 => return "Multi-Status",
347+
208 => return "Already Reported",
348+
226 => return "IM Used",
349+
350+
300 => return "Multiple Choices",
351+
301 => return "Moved Permanently",
352+
302 => return "Found",
353+
303 => return "See Other",
354+
304 => return "Not Modified",
355+
305 => return "Use Proxy",
356+
306 => return "Switch Proxy",
357+
307 => return "Temporary Redirect",
358+
308 => return "Permanent Redirect",
359+
360+
400 => return "Bad Request",
361+
401 => return "Unauthorized",
362+
402 => return "Payment Required",
363+
403 => return "Forbidden",
364+
404 => return "Not Found",
365+
405 => return "Method Not Allowed",
366+
406 => return "Not Acceptable",
367+
407 => return "Proxy Authentication Required",
368+
408 => return "Request Timeout",
369+
409 => return "Conflict",
370+
410 => return "Gone",
371+
411 => return "Length Required",
372+
412 => return "Precondition Failed",
373+
413 => return "Payload Too Large",
374+
414 => return "URI Too Long",
375+
415 => return "Unsupported Media Type",
376+
416 => return "Range Not Satisfiable",
377+
417 => return "Expectation Failed",
378+
418 => return "I'm a teapot",
379+
421 => return "Misdirected Request",
380+
422 => return "Unprocessable Entity",
381+
423 => return "Locked",
382+
424 => return "Failed Dependency",
383+
425 => return "Too Early",
384+
426 => return "Upgrade Required",
385+
428 => return "Precondition Required",
386+
429 => return "Too Many Requests",
387+
431 => return "Request Header Fields Too Large",
388+
451 => return "Unavailable For Legal Reasons",
389+
390+
500 => return "Internal Server Error",
391+
501 => return "Not Implemented",
392+
502 => return "Bad Gateway",
393+
503 => return "Service Unavailable",
394+
504 => return "Gateway Timeout",
395+
505 => return "HTTP Version Not Supported",
396+
506 => return "Variant Also Negotiates",
397+
507 => return "Insufficient Storage",
398+
508 => return "Loop Detected",
399+
510 => return "Not Extended",
400+
511 => return "Network Authentication Required",
401+
else => return "Unknown",
402+
}
403+
}
404+
331405
const testing = @import("../testing.zig");
332406
test "cdp.network setExtraHTTPHeaders" {
333407
var ctx = testing.context();

0 commit comments

Comments
 (0)