Handle scripts that don't return a 200 status code

This was already being handled for async scripts, but for sync scripts, we'd
log the error then proceed to try and execute the body (which would be some
error message).

This allows the header_callback to return a boolean to indicate whether or not
the http client should continue to process the request or abort it.
This commit is contained in:
Karl Seguin
2026-01-22 14:15:00 +08:00
parent c095950ef9
commit f6397e2731
5 changed files with 45 additions and 20 deletions

View File

@@ -89,7 +89,7 @@ pub fn deinit(self: *Fetch) void {
}
}
fn httpHeaderDoneCallback(transfer: *Http.Transfer) !void {
fn httpHeaderDoneCallback(transfer: *Http.Transfer) !bool {
const self: *Fetch = @ptrCast(@alignCast(transfer.ctx));
if (transfer.getContentLength()) |cl| {
@@ -133,6 +133,8 @@ fn httpHeaderDoneCallback(transfer: *Http.Transfer) !void {
while (it.next()) |hdr| {
try res._headers.append(hdr.name, hdr.value, self._page);
}
return true;
}
fn httpDataCallback(transfer: *Http.Transfer, data: []const u8) !void {