diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2013-12-20 09:42:39 -0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2013-12-20 09:42:39 -0800 |
commit | 259d205ff6c44e086371f2a7b28a9345257d094e (patch) | |
tree | 92d1d8306cc233b46d9f1190192f3077f5f0c876 /lib/pure | |
parent | 22e88026afc9e662206aea5c6de742ed680cc3dd (diff) | |
parent | 7d5fa3f52d23c4f238c1664fc568eb7f3c6a34b6 (diff) | |
download | Nim-259d205ff6c44e086371f2a7b28a9345257d094e.tar.gz |
Merge pull request #759 from zielmicha/stdmsg
Write tracebacks to stderr instead of stdout.
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/cgi.nim | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim index c499abdc0..29c686fd7 100644 --- a/lib/pure/cgi.nim +++ b/lib/pure/cgi.nim @@ -342,16 +342,35 @@ proc writeContentType*() = ## ## .. code-block:: Nimrod ## write(stdout, "Content-type: text/html\n\n") - ## - ## It also modifies the debug stack traces so that they contain - ## ``<br />`` and are easily readable in a browser. write(stdout, "Content-type: text/html\n\n") - system.stackTraceNewLine = "<br />\n" -proc setStackTraceNewLine*() = - ## Modifies the debug stack traces so that they contain - ## ``<br />`` and are easily readable in a browser. - system.stackTraceNewLine = "<br />\n" +proc resetForStacktrace() = + stdout.write """<!--: spam +Content-Type: text/html + +<body bgcolor=#f0f0f8><font color=#f0f0f8 size=-5> --> +<body bgcolor=#f0f0f8><font color=#f0f0f8 size=-5> --> --> +</font> </font> </font> </script> </object> </blockquote> </pre> +</table> </table> </table> </table> </table> </font> </font> </font> +""" + +proc writeErrorMessage*(data: string) = + ## Tries to reset browser state and writes `data` to stdout in + ## <plaintext> tag. + resetForStacktrace() + # We use <plaintext> here, instead of escaping, so stacktrace can + # be understood by human looking at source. + stdout.write("<plaintext>\n") + stdout.write(data) + +proc setStackTraceStdout*() = + ## Makes Nimrod output stacktraces to stdout, instead of server log. + errorMessageWriter = writeErrorMessage + +proc setStackTraceNewLine*() {.deprecated.} = + ## Makes Nimrod output stacktraces to stdout, instead of server log. + ## Depracated alias for setStackTraceStdout. + setStackTraceStdout() proc setCookie*(name, value: string) = ## Sets a cookie. @@ -374,4 +393,3 @@ when isMainModule: const test1 = "abc\L+def xyz" assert UrlEncode(test1) == "abc%0A%2Bdef+xyz" assert UrlDecode(UrlEncode(test1)) == test1 - |