Mercurial Hosting > luan
comparison http/src/luan/modules/http/Http.luan @ 508:9218f9cf45d3
various fixes
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 May 2015 20:20:54 -0600 |
parents | dbdf4b8193a8 |
children | e3b0846dc2ef |
comparison
equal
deleted
inserted
replaced
507:40e18d335da9 | 508:9218f9cf45d3 |
---|---|
1 java() | 1 java() |
2 local Luan = require "luan:Luan" | 2 local Luan = require "luan:Luan" |
3 local ipairs = Luan.ipairs | 3 local ipairs = Luan.ipairs |
4 local pairs = Luan.pairs | 4 local pairs = Luan.pairs |
5 local error = Luan.error | |
5 local set_metatable = Luan.set_metatable | 6 local set_metatable = Luan.set_metatable |
6 local Io = require "luan:Io" | 7 local Io = require "luan:Io" |
7 local Html = require "luan:Html" | 8 local Html = require "luan:Html" |
8 local url_encode = Html.url_encode | 9 local url_encode = Html.url_encode |
9 local HttpServicer = require "java:luan.modules.http.HttpServicer" | 10 local HttpServicer = require "java:luan.modules.http.HttpServicer" |
13 | 14 |
14 local singular_metatable = {} | 15 local singular_metatable = {} |
15 | 16 |
16 function singular_metatable.__index(table,key) | 17 function singular_metatable.__index(table,key) |
17 local list = table.__plural[key] | 18 local list = table.__plural[key] |
18 return list and list[1] | 19 return list and (list[1] or error("invalid value "..list.." for "..key)) |
19 end | 20 end |
20 | 21 |
21 function singular_metatable.__new_index(table,key,value) | 22 function singular_metatable.__new_index(table,key,value) |
22 table.__plural[key] = value and {value} | 23 table.__plural[key] = value and {value} |
23 end | 24 end |
92 if this.java ~= nil then | 93 if this.java ~= nil then |
93 this.send_redirect = this.java.sendRedirect | 94 this.send_redirect = this.java.sendRedirect |
94 this.send_error = this.java.sendError | 95 this.send_error = this.java.sendError |
95 | 96 |
96 function this.set_cookie(name,value,is_persistent,domain) | 97 function this.set_cookie(name,value,is_persistent,domain) |
97 HttpServicer.setCookie(this.java,M.response.java,name,value,is_persistent,domain) | 98 HttpServicer.setCookie(M.request.java,this.java,name,value,is_persistent,domain) |
98 end | 99 end |
99 | 100 |
100 function this.remove_cookie(name,domain) | 101 function this.remove_cookie(name,domain) |
101 HttpServicer.removeCookie(this.java,M.response.java,name,domain) | 102 HttpServicer.removeCookie(M.request.java,this.java,name,domain) |
102 end | 103 end |
103 | 104 |
104 function this.text_writer() | 105 function this.text_writer() |
105 return IoLuan.textWriter(this.java.getWriter()) | 106 return IoLuan.textWriter(this.java.getWriter()) |
106 end | 107 end |