summaryrefslogtreecommitdiff
path: root/rc/bin/rc-httpd/handlers/error
diff options
context:
space:
mode:
authorstanley lieber <stanley.lieber@gmail.com>2013-02-04 16:40:05 -0600
committerstanley lieber <stanley.lieber@gmail.com>2013-02-04 16:40:05 -0600
commitc877493fb00717de1a22860d88efb75ebf14ebec (patch)
treecb3cb0e47598e2880cdd20367925102856d41a5d /rc/bin/rc-httpd/handlers/error
parent0b212ed5054cd08bbc14a12936c07bc1ff5890a2 (diff)
downloadplan9front-c877493fb00717de1a22860d88efb75ebf14ebec.tar.xz
add rc-httpd
Diffstat (limited to 'rc/bin/rc-httpd/handlers/error')
-rwxr-xr-xrc/bin/rc-httpd/handlers/error38
1 files changed, 38 insertions, 0 deletions
diff --git a/rc/bin/rc-httpd/handlers/error b/rc/bin/rc-httpd/handlers/error
new file mode 100755
index 000000000..e38d41f01
--- /dev/null
+++ b/rc/bin/rc-httpd/handlers/error
@@ -0,0 +1,38 @@
+#!/bin/rc
+# DO NOT make this script callable directly from the web!
+fn do_error{
+ echo 'HTTP/1.1 '^$1^$cr
+ emit_extra_headers
+ echo 'Content-type: text/html'^$cr
+ echo $cr
+ echo '<html>
+<head>
+<title>'^$1^'</title>
+</head>
+<body>
+<h1>'^$1^'</h1>'
+ echo $2
+ echo '<p><i>rc-httpd at' $SERVER_NAME '</i>'
+ echo '
+ </body>
+ </html>
+ '
+}
+
+fn 404{
+ do_error '404 Not Found' \
+ 'The requested path '^$"location^' was not found on this server.'
+}
+
+fn 500{
+ do_error '500 Internal Server Error' \
+ 'The server has encountered an internal misconfiguration and is unable to satisfy your request.'
+}
+
+fn 503{
+ do_error '503 Forbidden' \
+ 'You do not have permission to access '^$"location^' on this server.'
+}
+
+do_log $1
+$1