Mercurial Hosting > luan
diff http/src/luan/modules/http/run.luan @ 580:1e69d9c21461
add Table.clear();
add Http.response.reset();
fix http/run;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 21 Jul 2015 14:56:41 -0600 |
parents | 2f39468680be |
children | ca169567ce07 |
line wrap: on
line diff
--- a/http/src/luan/modules/http/run.luan Thu Jul 16 15:14:31 2015 -0600 +++ b/http/src/luan/modules/http/run.luan Tue Jul 21 14:56:41 2015 -0600 @@ -4,11 +4,13 @@ local try = Luan.try or error() local Io = require "luan:Io" local print = Io.print or error() +local String = require "luan:String" +local gmatch = String.gmatch or error() local Http = require "luan:http/Http" local function lines(s) - local matcher = s.gmatch "([^\n]*)\n|([^\n])+$" + local matcher = gmatch(s,"([^\n]*)\n|([^\n])+$") return function() local m1, m2 = matcher() return m1 or m2 @@ -72,16 +74,16 @@ <% end return function() + local content_type = Http.request.parameter.content_type + if content_type ~= nil then + Http.response.header.content_type = content_type + end Io.stdout = Http.response.text_writer() local code = Http.request.parameter.code if code == nil then form() return end - local content_type = Http.request.parameter.content_type - if content_type ~= nil then - Http.response.header.content_type = content_type - end local env = { request = Http.request; response = Http.response; @@ -92,10 +94,12 @@ run() end; catch = function(e) + Http.response.reset() Http.response.header.content_type = "text/plain" + Io.stdout = Http.response.text_writer() print(e) - print() - print() + print"" + print"" print_with_line_numbers(code) end; }