diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-12 22:53:49 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-12 23:04:47 +0100 |
commit | 64e6debefbc2ab00735b83ae1def168775006844 (patch) | |
tree | 0262e1b875c05ca453885bde0b24281047f87e4d /src/loader/response.nim | |
parent | 2a8f0e7061babf03bc614554e3d5fd32220c305c (diff) | |
download | chawan-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.nim | 6 |
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) |