diff http/src/luan/modules/http/Http.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 92c3d22745b8
line wrap: on
line diff
--- a/http/src/luan/modules/http/Http.luan	Mon May 18 14:24:50 2015 -0600
+++ b/http/src/luan/modules/http/Http.luan	Mon May 18 20:59:30 2015 -0600
@@ -10,9 +10,6 @@
 local IoLuan = require "java:luan.modules.IoLuan"
 
 
-to_header_name = HttpServicer.toHeaderName
-
-
 local singular_metatable = {}
 
 function singular_metatable.__index(table,key)
@@ -21,7 +18,7 @@
 end
 
 function singular_metatable.__new_index(table,key,value)
-	table.__plural[key] = {value}
+	table.__plural[key] = value and {value}
 end
 
 function singular_metatable.__pairs(table)
@@ -65,7 +62,7 @@
 		end
 		out.close()
 		local s = string_uri.read_text()
-		return s == "" and nil or s
+		return s ~= "" and s or nil
 	end
 
 	function this.url()
@@ -105,6 +102,10 @@
 		function this.text_writer()
 			return IoLuan.textWriter(this.java.getWriter())
 		end
+
+		function this.binary_writer()
+			return IoLuan.binaryWriter(this.java.getOutputStream())
+		end
 	end
 	return this
 end
@@ -127,7 +128,7 @@
 		local old_out = Io.stdout
 		local mod = require("site:"..path)
 		mod.respond()
-		text_writer.close()
+		test.text_writer.close()
 		Io.stdout = old_out
 		return result.read_text()
 	end
@@ -137,12 +138,12 @@
 	request = new_request{}
 	request.cookies = test.cookies
 
-	response = {
+	response = new_response{
 
 		text_writer = function()
 			result = Io.uri "string:"
-			text_writer = result.text_writer()
-			return text_writer
+			test.text_writer = result.text_writer()
+			return test.text_writer
 		end;
 
 		set_cookie = function(name,value)
@@ -157,8 +158,6 @@
 			response.redirect = url
 		end;
 
-		headers = {};
-
 	}
 
 end