about summary refs log tree commit diff stats
path: root/src/loader/response.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-07-19 18:12:44 +0200
committerbptato <nincsnevem662@gmail.com>2024-07-19 18:16:12 +0200
commit0d08ee8959d126d652fc42e9af63dbc8cc1d93ba (patch)
tree1b597924989f1eb3e4b96714c69e385af97d7186 /src/loader/response.nim
parentf94b84bde340739647ffe7dd92cfcefb6686eca2 (diff)
downloadchawan-0d08ee8959d126d652fc42e9af63dbc8cc1d93ba.tar.gz
loader: async status/headers for fetch
The status code & headers are no longer guaranteed to be sent right
after res/outputId, so read them asynchronously instead.

(This is pretty much the same code as the buffer connection handler in
pager. Hopefully we can merge the two at some point.)
Diffstat (limited to 'src/loader/response.nim')
-rw-r--r--src/loader/response.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/loader/response.nim b/src/loader/response.nim
index 8b33621e..5531da9d 100644
--- a/src/loader/response.nim
+++ b/src/loader/response.nim
@@ -59,13 +59,15 @@ type
 
 jsDestructor(Response)
 
-proc newResponse*(res: int; request: Request; stream: SocketStream): Response =
+proc newResponse*(res: int; request: Request; stream: SocketStream;
+    outputId: int; status: uint16): Response =
   return Response(
     res: res,
     url: request.url,
     body: stream,
     bodyRead: EmptyPromise(),
-    outputId: -1
+    outputId: outputId,
+    status: status
   )
 
 func makeNetworkError*(): Response {.jsstfunc: "Response.error".} =