diff options
-rw-r--r-- | src/javascript/jsc/webcore/response.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/javascript/jsc/webcore/response.zig b/src/javascript/jsc/webcore/response.zig index 0fa5507c7..2cb4b50da 100644 --- a/src/javascript/jsc/webcore/response.zig +++ b/src/javascript/jsc/webcore/response.zig @@ -102,6 +102,10 @@ pub const Response = struct { .@"get" = getBodyUsed, .ro = true, }, + .@"type" = .{ + .@"get" = getResponseType, + .ro = true, + }, }, ); @@ -169,6 +173,20 @@ pub const Response = struct { return ZigString.init(this.url).withEncoding().toValueGC(ctx.ptr()).asObjectRef(); } + pub fn getResponseType( + this: *Response, + ctx: js.JSContextRef, + _: js.JSValueRef, + _: js.JSStringRef, + _: js.ExceptionRef, + ) js.JSValueRef { + if (this.body.init.status_code < 200) { + return ZigString.init("error").toValue(ctx.ptr()).asObjectRef(); + } + + return ZigString.init("basic").toValue(ctx.ptr()).asObjectRef(); + } + pub fn getBodyUsed( this: *Response, _: js.JSContextRef, |