webapi: xhr/fetch report status reason from server

If the server gives a status reason, report it as-is. Only default to the
zig code->reason map when one isn't given.

Also, don't force a 407 status code when auth_challenge is present.
This commit is contained in:
Karl Seguin committed 2026-09-28 19:01:39 +08:00
1 parent 58357fea3e
commit f7fbc2f34f
6 files changed
+133 -6

No files matched your search

+16
View File
@@ -884,6 +884,22 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {
return req.respond("", .{ .status = @enumFromInt(code) });
}
if (std.mem.eql(u8, path, "/xhr/reason")) {
return req.respond("", .{
.status = .service_unavailable,
.reason = "HOUSTON WE HAVE A",
});
}
if (std.mem.eql(u8, path, "/xhr/401")) {
return req.respond("No", .{
.status = .unauthorized,
.extra_headers = &.{
.{ .name = "WWW-Authenticate", .value = "Basic realm=\"test\"" },
},
});
}
if (std.mem.eql(u8, path, "/xhr/500")) {
return req.respond("Internal Server Error", .{
.status = .internal_server_error,