about summary refs log tree commit diff stats
path: root/src/loader/cgi.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-15 18:42:21 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-15 18:43:49 +0100
commitdab0d1cd21e216da5551e807489a704ae7b3cb42 (patch)
tree25f736d1b3b76659784ade93ac812a104cc22db4 /src/loader/cgi.nim
parentd67caf71c96629056275432f1ab5b5510db23c0b (diff)
downloadchawan-dab0d1cd21e216da5551e807489a704ae7b3cb42.tar.gz
Implement local CGI error message handling
This was documented, but not implemented until now.

Also, improve the loader module's protocol documentation.
Diffstat (limited to 'src/loader/cgi.nim')
-rw-r--r--src/loader/cgi.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/loader/cgi.nim b/src/loader/cgi.nim
index 8fe96274..dfe66e22 100644
--- a/src/loader/cgi.nim
+++ b/src/loader/cgi.nim
@@ -87,7 +87,13 @@ proc handleFirstLine(handle: LoaderHandle, line: string, headers: Headers,
       else:
         let fb = int32(ERROR_CGI_INVALID_CHA_CONTROL)
         let code = int(parseInt32(errs[1]).get(fb))
-        discard handle.sendResult(code)
+        var message = ""
+        if errs.len > 2:
+          message &= errs[2]
+          for i in 3 ..< errs.len:
+            message &= ' '
+            message &= errs[i]
+        discard handle.sendResult(code, message)
       return RESULT_ERROR
     elif v.startsWithIgnoreCase("ControlDone"):
       return RESULT_CONTROL_DONE