mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 08:18:59 +00:00
xhr: start implementation
This commit is contained in:
58
src/xhr/xhr.zig
Normal file
58
src/xhr/xhr.zig
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const generate = @import("../generate.zig");
|
||||||
|
const EventTarget = @import("../dom/event_target.zig").EventTarget;
|
||||||
|
|
||||||
|
// XHR interfaces
|
||||||
|
// https://xhr.spec.whatwg.org/#interface-xmlhttprequest
|
||||||
|
pub const Interfaces = generate.Tuple(.{
|
||||||
|
XMLHttpRequestEventTarget,
|
||||||
|
XMLHttpRequestUpload,
|
||||||
|
});
|
||||||
|
|
||||||
|
pub const XMLHttpRequestEventTarget = struct {
|
||||||
|
pub const prototype = *EventTarget;
|
||||||
|
pub const mem_guarantied = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const XMLHttpRequestUpload = struct {
|
||||||
|
pub const prototype = *XMLHttpRequestEventTarget;
|
||||||
|
pub const mem_guarantied = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const XMLHttpRequest = struct {
|
||||||
|
pub const prototype = *XMLHttpRequestEventTarget;
|
||||||
|
pub const mem_guarantied = true;
|
||||||
|
|
||||||
|
pub fn constructor() XMLHttpRequest {
|
||||||
|
return XMLHttpRequest{};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const UNSENT: u16 = 0;
|
||||||
|
pub const OPENED: u16 = 1;
|
||||||
|
pub const HEADERS_RECEIVED: u16 = 2;
|
||||||
|
pub const LOADING: u16 = 3;
|
||||||
|
pub const DONE: u16 = 4;
|
||||||
|
|
||||||
|
readyState: u16 = UNSENT,
|
||||||
|
|
||||||
|
pub fn get_readyState(self: *XMLHttpRequest) u16 {
|
||||||
|
return self.readyState;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn _open(
|
||||||
|
self: *XMLHttpRequest,
|
||||||
|
method: []const u8,
|
||||||
|
url: []const u8,
|
||||||
|
asyn: ?bool,
|
||||||
|
username: ?[]const u8,
|
||||||
|
password: ?[]const u8,
|
||||||
|
) !void {
|
||||||
|
_ = self;
|
||||||
|
_ = method;
|
||||||
|
_ = url;
|
||||||
|
_ = asyn;
|
||||||
|
_ = username;
|
||||||
|
_ = password;
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user