mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-10-09 12:51:45 -04:00
webapi: improve fetch/response correctness with null bodies
Responses with specific status (e.g. 204) should always have a null body. Also adds validation to Response constructor (e.g. can't provide an invalid status). Improves a handful of WPT tests: fetch/api/response/response-error.any.html fetch/api/response/response-static-json.any.html
This commit is contained in:
5 files changed
+96
-5
No files matched your search
@@ -866,6 +866,11 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {
|
||||
});
|
||||
}
|
||||
|
||||
if (std.mem.startsWith(u8, path, "/status/")) {
|
||||
const code = try std.fmt.parseInt(u16, path["/status/".len..], 10);
|
||||
return req.respond("", .{ .status = @enumFromInt(code) });
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, path, "/xhr/500")) {
|
||||
return req.respond("Internal Server Error", .{
|
||||
.status = .internal_server_error,
|
||||
|
||||
Reference in new issue
Block a user