Mercurial Hosting > luan
view src/luan/modules/http/tools/Dump_mod.luan @ 1160:4beabb087be6
add http/impl
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 05 Feb 2018 22:33:59 -0700 |
parents | 0842b9b570f8 |
children | 668f29bc52ea |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local pairs = Luan.pairs or error() local ipairs = Luan.ipairs or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Dump_mod = {} function Dump_mod.respond() Http.response.headers["content-type"] = "text/plain" Io.stdout = Http.response.text_writer() local method = Http.request.method local path = Http.request.full_path() %> <%=method%> <%=path%> <%=Http.request.protocol%> <% Dump_mod.dump_headers(Http.request.headers) %> <% if method == "POST" then %> <%=Io.repr(Http.request.parameters)%> <% end end function Dump_mod.dump_headers(headers) for name, values in pairs(headers) do for _, value in ipairs(values) do %> <%=name%>: <%=value%> <% end end end return Dump_mod