mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-31 09:29:42 +00:00
Execute script.onload/onerror
Add object-support for URLSearchParams. Start to treat js.Value as a first class object (instead of js.Object, where appropriate).
This commit is contained in:
@@ -34,6 +34,7 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
const Fetch = @This();
|
||||
|
||||
_page: *Page,
|
||||
_url: []const u8,
|
||||
_buf: std.ArrayList(u8),
|
||||
_response: *Response,
|
||||
_resolver: js.PersistentPromiseResolver,
|
||||
@@ -48,6 +49,7 @@ pub fn init(input: Input, page: *Page) !js.Promise {
|
||||
fetch.* = .{
|
||||
._page = page,
|
||||
._buf = .empty,
|
||||
._url = try page.arena.dupe(u8, request._url),
|
||||
._resolver = try page.js.createPromiseResolver(.page),
|
||||
._response = try Response.init(null, .{ .status = 0 }, page),
|
||||
};
|
||||
@@ -58,6 +60,7 @@ pub fn init(input: Input, page: *Page) !js.Promise {
|
||||
if (comptime IS_DEBUG) {
|
||||
log.debug(.http, "fetch", .{ .url = request._url });
|
||||
}
|
||||
std.debug.print("fetch: {s}\n", .{request._url});
|
||||
|
||||
try http_client.request(.{
|
||||
.ctx = fetch,
|
||||
@@ -97,6 +100,7 @@ fn httpDataCallback(transfer: *Http.Transfer, data: []const u8) !void {
|
||||
fn httpDoneCallback(ctx: *anyopaque) !void {
|
||||
const self: *Fetch = @ptrCast(@alignCast(ctx));
|
||||
self._response._body = self._buf.items;
|
||||
std.debug.print("fetch-resolve: {s}\n", .{self._url});
|
||||
return self._resolver.resolve(self._response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user