diff options
author | bptato <nincsnevem662@gmail.com> | 2024-06-22 23:56:04 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-06-22 23:56:28 +0200 |
commit | 3aaddac030f612fd5221d1d0b6ea501a135459ac (patch) | |
tree | bcb0fae9f8daa1b476b0e31738a94b48cad76c4b /src/loader | |
parent | ddffd4502dad948121244cddc4847250d7a87d40 (diff) | |
download | chawan-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.nim | 6 |
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) |