HttpClient Improvements

1 - Track owner of a request (for simpler / more accurate abort (TBD))

2 - Create Transfer upfront, make everything work on Transfer (not Request)
    This helps remove ambiguity about cleanup and simplifies layers. For example
    Robots request is just another normal request, not a special case. This gives
    everything a stable address (the *Transfer which can be looked up by id)
This commit is contained in:
Karl Seguin committed 2026-05-12 19:26:24 +08:00
1 parent 49297d76d3
commit 82a4fc752b
20 files changed
+550 -528

No files matched your search

+11 -11
View File
@@ -18,13 +18,15 @@
const std = @import("std");
const lp = @import("lightpanda");
const log = lp.log;
const WebBotAuth = @import("../WebBotAuth.zig");
const URL = @import("../../browser/URL.zig");
const WebBotAuth = @import("../WebBotAuth.zig");
const Client = @import("../../browser/HttpClient.zig").Client;
const Request = @import("../../browser/HttpClient.zig").Request;
const Layer = @import("../../browser/HttpClient.zig").Layer;
const Client = @import("../../browser/HttpClient.zig").Client;
const Transfer = @import("../../browser/HttpClient.zig").Transfer;
const log = lp.log;
const WebBotAuthLayer = @This();
@@ -37,15 +39,13 @@ pub fn layer(self: *WebBotAuthLayer) Layer {
};
}
fn request(ptr: *anyopaque, client: *Client, req: Request) anyerror!void {
fn request(ptr: *anyopaque, transfer: *Transfer) anyerror!void {
const self: *WebBotAuthLayer = @ptrCast(@alignCast(ptr));
var our_req = req;
const wba = client.network.web_bot_auth orelse @panic("WebBotAuthLayer shouldn't be active without WebBotAuth");
const wba = transfer.client.network.web_bot_auth orelse @panic("WebBotAuthLayer shouldn't be active without WebBotAuth");
const arena = req.params.arena;
const authority = URL.getHost(req.params.url);
try wba.signRequest(arena, &our_req.params.headers, authority);
const authority = URL.getHost(transfer.url);
try wba.signRequest(transfer.arena, &transfer.req.params.headers, authority);
return self.next.request(client, our_req);
return self.next.request(transfer);
}