changeset 508:9218f9cf45d3

various fixes
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 May 2015 20:20:54 -0600
parents 40e18d335da9
children e3b0846dc2ef
files core/src/luan/modules/Luan.luan http/src/luan/modules/http/Http.luan http/src/luan/modules/http/Http_test.luan http/src/luan/modules/http/test.luan
diffstat 4 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/modules/Luan.luan	Thu May 21 17:03:57 2015 -0600
+++ b/core/src/luan/modules/Luan.luan	Thu May 21 20:20:54 2015 -0600
@@ -28,8 +28,8 @@
 M.type = BasicLuan.type
 M.values = BasicLuan.values
 
-function M.do_file(uri)
-	return M.load_file(uri)()
+function M.do_file(uri,add_extension)
+	return M.load_file(uri,add_extension)()
 end
 
 M.VERSION = M.do_file "classpath:luan/version.luan"
--- a/http/src/luan/modules/http/Http.luan	Thu May 21 17:03:57 2015 -0600
+++ b/http/src/luan/modules/http/Http.luan	Thu May 21 20:20:54 2015 -0600
@@ -2,6 +2,7 @@
 local Luan = require "luan:Luan"
 local ipairs = Luan.ipairs
 local pairs = Luan.pairs
+local error = Luan.error
 local set_metatable = Luan.set_metatable
 local Io = require "luan:Io"
 local Html = require "luan:Html"
@@ -15,7 +16,7 @@
 
 function singular_metatable.__index(table,key)
 	local list = table.__plural[key]
-	return list and list[1]
+	return list and (list[1] or error("invalid value "..list.." for "..key))
 end
 
 function singular_metatable.__new_index(table,key,value)
@@ -94,11 +95,11 @@
 		this.send_error = this.java.sendError
 
 		function this.set_cookie(name,value,is_persistent,domain)
-			HttpServicer.setCookie(this.java,M.response.java,name,value,is_persistent,domain)
+			HttpServicer.setCookie(M.request.java,this.java,name,value,is_persistent,domain)
 		end
 
 		function this.remove_cookie(name,domain)
-			HttpServicer.removeCookie(this.java,M.response.java,name,domain)
+			HttpServicer.removeCookie(M.request.java,this.java,name,domain)
 		end
 
 		function this.text_writer()
--- a/http/src/luan/modules/http/Http_test.luan	Thu May 21 17:03:57 2015 -0600
+++ b/http/src/luan/modules/http/Http_test.luan	Thu May 21 20:20:54 2015 -0600
@@ -4,7 +4,7 @@
 local M = {}
 
 M.welcome_file = "index.html"
-M.cookies = {}
+M.cookie = {}
 
 function M.get_page(path)
 	if M.welcome_file ~= nil and path.matches ".*/" then
@@ -20,7 +20,7 @@
 
 function M.init()
 	Http.request = Http.new_request{}
-	Http.request.cookies = M.cookies
+	Http.request.cookie = M.cookie
 
 	Http.response = Http.new_response{
 
@@ -31,11 +31,11 @@
 		end;
 
 		set_cookie = function(name,value)
-			M.cookies[name] = value
+			M.cookie[name] = value
 		end;
 
 		remove_cookie = function(name)
-			M.cookies[name] = nil
+			M.cookie[name] = nil
 		end;
 
 		send_redirect = function(url)
--- a/http/src/luan/modules/http/test.luan	Thu May 21 17:03:57 2015 -0600
+++ b/http/src/luan/modules/http/test.luan	Thu May 21 20:20:54 2015 -0600
@@ -1,3 +1,4 @@
+local Luan = require "luan:Luan"
 local Io = require "luan:Io"
 local Server = require "luan:http/Server"
 
@@ -8,4 +9,4 @@
 
 local dir, test = ...
 Server.init(dir)
-require(test)
+Luan.do_file(test,true)