about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-06-22 23:56:04 +0200
committerbptato <nincsnevem662@gmail.com>2024-06-22 23:56:28 +0200
commit3aaddac030f612fd5221d1d0b6ea501a135459ac (patch)
treebcb0fae9f8daa1b476b0e31738a94b48cad76c4b /src/loader
parentddffd4502dad948121244cddc4847250d7a87d40 (diff)
downloadchawan-3aaddac030f612fd5221d1d0b6ea501a135459ac.tar.gz
loader: fix failing assertion
There is no guarantee that iclose is called exactly at rsBeforeStatus
or rsBeforeHeaders.
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/loaderhandle.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/loader/loaderhandle.nim b/src/loader/loaderhandle.nim
index 42f10c6e..13869c8f 100644
--- a/src/loader/loaderhandle.nim
+++ b/src/loader/loaderhandle.nim
@@ -175,8 +175,10 @@ proc iclose*(handle: LoaderHandle) =
       # not an ideal solution, but better than silently eating malformed
       # headers
       try:
-        handle.sendStatus(500)
-        handle.sendHeaders(newHeaders())
+        if handle.rstate == rsBeforeStatus:
+          handle.sendStatus(500)
+        if handle.rstate == rsBeforeHeaders:
+          handle.sendHeaders(newHeaders())
         handle.output.ostream.setBlocking(true)
         const msg = "Error: malformed header in CGI script"
         discard handle.output.ostream.sendData(msg)