about summary refs log tree commit diff stats
path: root/src/io/request.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-08 08:03:16 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-08 08:03:16 +0200
commit00d7836d8a3d0101bd282e3acce58d65ed0220fe (patch)
tree70ff6f736277ab277bf527b4e3b79771bb7e3935 /src/io/request.nim
parent23339918fa58f570a2b12bc7c7e78d4d8681b9a2 (diff)
downloadchawan-00d7836d8a3d0101bd282e3acce58d65ed0220fe.tar.gz
Remove JSObject again, add File API constructor
Diffstat (limited to 'src/io/request.nim')
-rw-r--r--src/io/request.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/io/request.nim b/src/io/request.nim
index 08947bd5..ed38ad47 100644
--- a/src/io/request.nim
+++ b/src/io/request.nim
@@ -186,10 +186,13 @@ proc fill(headers: Headers, ctx: JSContext, val: JSValue) =
         else:
           headers.table[k] = @[v]
 
-func newHeaders*(obj = none(JSObject)): Headers {.jsctor.} =
+func newHeaders*(): Headers =
+  new(result)
+
+func newHeaders*(ctx: JSContext, obj = none(JSValue)): Headers {.jsctor.} =
   new(result)
   if obj.isSome:
-    result.fill(obj.get.ctx, obj.get.val)
+    result.fill(ctx, obj.get)
 
 func newHeaders*(table: Table[string, string]): Headers =
   new(result)
@@ -239,8 +242,7 @@ func createPotentialCORSRequest*(url: URL, destination: RequestDestination, cors
   return newRequest(url, destination = destination, mode = mode, credentialsMode = credentialsMode)
 
 #TODO resource as Request
-#TODO also, I'm not sure what to do with init. For now I've re-introduced
-# JSObject to make this work, but I really wish we had a better solution.
+#TODO init as an actual dictionary
 func newRequest*(ctx: JSContext, resource: string,
     init = none(JSValue)): Request {.jserr, jsctor.} =
   let x = parseURL(resource)