diff --git a/src/cdp/domains/network.zig b/src/cdp/domains/network.zig index 1c2eef93..cbe4c963 100644 --- a/src/cdp/domains/network.zig +++ b/src/cdp/domains/network.zig @@ -316,7 +316,7 @@ pub fn httpRequestComplete(arena: Allocator, bc: anytype, request: *const Notifi .response = .{ .url = url, .status = request.status, - .statusText = statusText(request.status), + .statusText = @as(std.http.Status, @enumFromInt(request.status)).phrase() orelse "Unknown", .headers = std.json.ArrayHashMap([]const u8){ .map = headers }, }, .frameId = target_id, @@ -329,79 +329,6 @@ fn urlToString(arena: Allocator, url: *const std.Uri, opts: std.Uri.WriteToStrea return buf.items; } -fn statusText(status: u16) []const u8 { - switch (status) { - 100 => return "Continue", - 101 => return "Switching Protocols", - 102 => return "Processing", - 103 => return "Early Hints", - - 200 => return "OK", - 201 => return "Created", - 202 => return "Accepted", - 203 => return "Non-Authoritative Information", - 204 => return "No Content", - 205 => return "Reset Content", - 206 => return "Partial Content", - 207 => return "Multi-Status", - 208 => return "Already Reported", - 226 => return "IM Used", - - 300 => return "Multiple Choices", - 301 => return "Moved Permanently", - 302 => return "Found", - 303 => return "See Other", - 304 => return "Not Modified", - 305 => return "Use Proxy", - 306 => return "Switch Proxy", - 307 => return "Temporary Redirect", - 308 => return "Permanent Redirect", - - 400 => return "Bad Request", - 401 => return "Unauthorized", - 402 => return "Payment Required", - 403 => return "Forbidden", - 404 => return "Not Found", - 405 => return "Method Not Allowed", - 406 => return "Not Acceptable", - 407 => return "Proxy Authentication Required", - 408 => return "Request Timeout", - 409 => return "Conflict", - 410 => return "Gone", - 411 => return "Length Required", - 412 => return "Precondition Failed", - 413 => return "Payload Too Large", - 414 => return "URI Too Long", - 415 => return "Unsupported Media Type", - 416 => return "Range Not Satisfiable", - 417 => return "Expectation Failed", - 418 => return "I'm a teapot", - 421 => return "Misdirected Request", - 422 => return "Unprocessable Entity", - 423 => return "Locked", - 424 => return "Failed Dependency", - 425 => return "Too Early", - 426 => return "Upgrade Required", - 428 => return "Precondition Required", - 429 => return "Too Many Requests", - 431 => return "Request Header Fields Too Large", - 451 => return "Unavailable For Legal Reasons", - - 500 => return "Internal Server Error", - 501 => return "Not Implemented", - 502 => return "Bad Gateway", - 503 => return "Service Unavailable", - 504 => return "Gateway Timeout", - 505 => return "HTTP Version Not Supported", - 506 => return "Variant Also Negotiates", - 507 => return "Insufficient Storage", - 508 => return "Loop Detected", - 510 => return "Not Extended", - 511 => return "Network Authentication Required", - else => return "Unknown", - } -} - const testing = @import("../testing.zig"); test "cdp.network setExtraHTTPHeaders" { var ctx = testing.context();