Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/xhr/xhr.zig
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,10 @@ pub const XMLHttpRequest = struct {
// https://xhr.spec.whatwg.org/#the-response-attribute
pub fn get_response(self: *XMLHttpRequest, alloc: std.mem.Allocator) !?Response {
if (self.response_type == .Empty or self.response_type == .Text) {
if (self.state == LOADING or self.state == DONE) return .{ .Text = "" };
return .{ .Text = try self.get_responseText() };
if (self.state == LOADING or self.state == DONE) {
return .{ .Text = try self.get_responseText() };
}
return .{ .Text = "" };
}

// fastpath if response is previously parsed.
Expand All @@ -774,6 +776,7 @@ pub const XMLHttpRequest = struct {
// response object to a new ArrayBuffer object representing this’s
// received bytes. If this throws an exception, then set this’s
// response object to failure and return null.
log.err("response type ArrayBuffer not implemented", .{});
return null;
}

Expand All @@ -782,6 +785,7 @@ pub const XMLHttpRequest = struct {
// response object to a new Blob object representing this’s
// received bytes with type set to the result of get a final MIME
// type for this.
log.err("response type Blob not implemented", .{});
return null;
}

Expand Down Expand Up @@ -944,7 +948,7 @@ pub fn testExecFn(
.{ .src = "req.getResponseHeader('Content-Type')", .ex = "text/html; charset=utf-8" },
.{ .src = "req.getAllResponseHeaders().length > 64", .ex = "true" },
.{ .src = "req.responseText.length > 64", .ex = "true" },
.{ .src = "req.response", .ex = "" },
.{ .src = "req.response.length == req.responseText.length", .ex = "true" },
.{ .src = "req.responseXML instanceof Document", .ex = "true" },
};
try checkCases(js_env, &send);
Expand Down