diff http/src/luan/modules/http/dump.luan @ 500:ab9c2afefb47

add response.binary_writer
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 18 May 2015 20:59:30 -0600
parents fa4af530697f
children 40e18d335da9
line wrap: on
line diff
--- a/http/src/luan/modules/http/dump.luan	Mon May 18 14:24:50 2015 -0600
+++ b/http/src/luan/modules/http/dump.luan	Mon May 18 20:59:30 2015 -0600
@@ -3,8 +3,12 @@
 local ipairs = Luan.ipairs
 local Io = require "luan:Io"
 local Http = require "luan:http/Http"
+java()
+local HttpServicer = require "java:luan.modules.http.HttpServicer"
 
 
+to_http_header_name = HttpServicer.toHttpHeaderName
+
 function respond()
 	Http.response.header.content_type = "text/plain"
 	Io.stdout = Http.response.text_writer()
@@ -18,14 +22,7 @@
 %>
 <%=method%> <%=path%> <%=Http.request.protocol%> 
 <%
-	for name, values in pairs(Http.request.headers) do
-		local header_name = Http.to_header_name(name)
-		for _, value in ipairs(values) do
-%>
-<%=header_name%>: <%=value%>
-<%
-		end
-	end
+	dump_headers(Http.request.headers)
 %>
 
 <%
@@ -35,3 +32,15 @@
 <%
 	end
 end
+
+
+function dump_headers(headers)
+	for name, values in pairs(headers) do
+		local header_name = to_http_header_name(name)
+		for _, value in ipairs(values) do
+%>
+<%=header_name%>: <%=value%>
+<%
+		end
+	end
+end