Skip to content

Commit 6344f03

Browse files
committed
xhr: fix invalid response with empty type
1 parent 8f7a8c0 commit 6344f03

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/xhr/xhr.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,10 @@ pub const XMLHttpRequest = struct {
756756
// https://xhr.spec.whatwg.org/#the-response-attribute
757757
pub fn get_response(self: *XMLHttpRequest, alloc: std.mem.Allocator) !?Response {
758758
if (self.response_type == .Empty or self.response_type == .Text) {
759-
if (self.state == LOADING or self.state == DONE) return .{ .Text = "" };
760-
return .{ .Text = try self.get_responseText() };
759+
if (self.state == LOADING or self.state == DONE) {
760+
return .{ .Text = try self.get_responseText() };
761+
}
762+
return .{ .Text = "" };
761763
}
762764

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

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

0 commit comments

Comments
 (0)