about summary refs log tree commit diff stats
path: root/src/loader/response.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-12 22:53:49 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-12 23:04:47 +0100
commit64e6debefbc2ab00735b83ae1def168775006844 (patch)
tree0262e1b875c05ca453885bde0b24281047f87e4d /src/loader/response.nim
parent2a8f0e7061babf03bc614554e3d5fd32220c305c (diff)
downloadchawan-64e6debefbc2ab00735b83ae1def168775006844.tar.gz
client: fix blocking reads on container connection
Sometimes, headers take a while to reach us even after the result has
been sent. e.g.

echo 'Cha-Control: Connected'
sleep 5
echo 'Cha-Control: ControlDone'

^ this froze the UI for 5 seconds, that's certainly not what we want.

Since we don't have a proper buffered reader yet, and I don't want to
write another disgusting hack like BufStream, we just use a state
machine to figure out how much we can read. Sounds bad, but in practice
it works just fine since loader's response patterns are very simple.
Diffstat (limited to 'src/loader/response.nim')
-rw-r--r--src/loader/response.nim6
1 files changed, 0 insertions, 6 deletions
diff --git a/src/loader/response.nim b/src/loader/response.nim
index f419c432..6b4ec64e 100644
--- a/src/loader/response.nim
+++ b/src/loader/response.nim
@@ -7,7 +7,6 @@ import io/promise
 import io/socketstream
 import js/error
 import js/javascript
-import loader/connecterror
 import loader/headers
 import loader/request
 import types/blob
@@ -154,10 +153,5 @@ proc json(ctx: JSContext, this: Response): Promise[JSResult[JSValue]]
     return ok(JS_ParseJSON(ctx, cstring(s), cast[csize_t](s.len),
       cstring"<input>")))
 
-func getErrorMessage*(this: Response): string =
-  if this.internalMessage != "":
-    return this.internalMessage
-  getLoaderErrorMessage(this.res)
-
 proc addResponseModule*(ctx: JSContext) =
   ctx.registerType(Response)