summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Renner Berthing <esmil@mailme.dk>2013-01-08 23:38:41 +0100
committerEmil Renner Berthing <esmil@mailme.dk>2013-01-09 21:49:46 +0100
commit12c0a611cdf15bf8f86d870af5fa97881a457b0a (patch)
tree4fbda78550b22a685acef35b539495c3188fcd22
parent95a5025a2080a5925c55c1f9346da14dd98ea89f (diff)
downloadlem-12c0a611cdf15bf8f86d870af5fa97881a457b0a.tar.gz
lem-12c0a611cdf15bf8f86d870af5fa97881a457b0a.tar.xz
lem-12c0a611cdf15bf8f86d870af5fa97881a457b0a.zip
http.server: add bad_request() and expose htmlerror()
-rw-r--r--lem/http/server.lua25
1 files changed, 12 insertions, 13 deletions
diff --git a/lem/http/server.lua b/lem/http/server.lua
index 69bdbb9..0ed8473 100644
--- a/lem/http/server.lua
+++ b/lem/http/server.lua
@@ -91,9 +91,8 @@ function M.not_found(req, res)
]])
end
-do
- local function htmlerror(num, text)
- local str = format([[
+function M.htmlerror(num, text)
+ local str = format([[
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
@@ -104,19 +103,19 @@ do
</body>
</html>
]], text, text)
- return function(req, res)
- res.status = num
- res.headers['Content-Type'] = 'text/html; charset=UTF-8'
- res.headers['Connection'] = 'close'
- res:add(str)
- end
+ return function(req, res)
+ res.status = num
+ res.headers['Content-Type'] = 'text/html; charset=UTF-8'
+ res.headers['Connection'] = 'close'
+ res:add(str)
end
-
- M.method_not_allowed = htmlerror(405, 'Method Not Allowed')
- M.expectation_failed = htmlerror(417, 'Expectation Failed')
- M.version_not_supported = htmlerror(505, 'HTTP Version Not Supported')
end
+M.method_not_allowed = M.htmlerror(405, 'Method Not Allowed')
+M.expectation_failed = M.htmlerror(417, 'Expectation Failed')
+M.version_not_supported = M.htmlerror(505, 'HTTP Version Not Supported')
+M.bad_request = M.htmlerror(400, 'Bad Request')
+
function M.debug() end
do