File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/javascript/jsc/webcore Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ pub const Response = struct {
102
102
.@"get" = getBodyUsed ,
103
103
.ro = true ,
104
104
},
105
+ .@"type" = .{
106
+ .@"get" = getResponseType ,
107
+ .ro = true ,
108
+ },
105
109
},
106
110
);
107
111
@@ -169,6 +173,20 @@ pub const Response = struct {
169
173
return ZigString .init (this .url ).withEncoding ().toValueGC (ctx .ptr ()).asObjectRef ();
170
174
}
171
175
176
+ pub fn getResponseType (
177
+ this : * Response ,
178
+ ctx : js.JSContextRef ,
179
+ _ : js.JSValueRef ,
180
+ _ : js.JSStringRef ,
181
+ _ : js.ExceptionRef ,
182
+ ) js.JSValueRef {
183
+ if (this .body .init .status_code < 200 ) {
184
+ return ZigString .init ("error" ).toValue (ctx .ptr ()).asObjectRef ();
185
+ }
186
+
187
+ return ZigString .init ("basic" ).toValue (ctx .ptr ()).asObjectRef ();
188
+ }
189
+
172
190
pub fn getBodyUsed (
173
191
this : * Response ,
174
192
_ : js.JSContextRef ,
You can’t perform that action at this time.
0 commit comments