Mercurial Hosting > luan
comparison http/src/luan/modules/http/Http.luan @ 498:ee55be414a34
Http.response is now mostly luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 18 May 2015 00:25:35 -0600 |
parents | 55f9f74f1e55 |
children | fa4af530697f |
comparison
equal
deleted
inserted
replaced
497:55f9f74f1e55 | 498:ee55be414a34 |
---|---|
1 java() | |
1 local Luan = require "luan:Luan" | 2 local Luan = require "luan:Luan" |
2 local ipairs = Luan.ipairs | 3 local ipairs = Luan.ipairs |
3 local pairs = Luan.pairs | 4 local pairs = Luan.pairs |
4 local set_metatable = Luan.set_metatable | 5 local set_metatable = Luan.set_metatable |
5 local Io = require "luan:Io" | 6 local Io = require "luan:Io" |
6 local Html = require "luan:Html" | 7 local Html = require "luan:Html" |
7 local url_encode = Html.url_encode | 8 local url_encode = Html.url_encode |
9 local HttpServicer = require "java:luan.modules.http.HttpServicer" | |
10 local IoLuan = require "java:luan.modules.IoLuan" | |
8 | 11 |
9 | 12 |
10 local singular_metatable = {} | 13 local singular_metatable = {} |
11 | 14 |
12 function singular_metatable.__index(table,key) | 15 function singular_metatable.__index(table,key) |
67 end | 70 end |
68 | 71 |
69 return this | 72 return this |
70 end | 73 end |
71 | 74 |
75 STATUS = { | |
76 OK = 200; | |
77 -- add more as needed | |
78 } | |
79 | |
80 function new_response(this) | |
81 this = new_common(this) | |
82 this.status = STATUS.OK | |
83 if this.java ~= nil then | |
84 this.send_redirect = this.java.sendRedirect | |
85 this.send_error = this.java.sendError | |
86 | |
87 function this.set_cookie(name,value,is_persistent,domain) | |
88 HttpServicer.setCookie(this.java,response.java,name,value,is_persistent,domain) | |
89 end | |
90 | |
91 function this.remove_cookie(name,domain) | |
92 HttpServicer.removeCookie(this.java,response.java,name,domain) | |
93 end | |
94 | |
95 function this.text_writer() | |
96 return IoLuan.textWriter(this.java.getWriter()) | |
97 end | |
98 end | |
99 return this | |
100 end | |
101 | |
72 -- request = new_request{} -- filled in by HttpServicer | 102 -- request = new_request{} -- filled in by HttpServicer |
73 | 103 |
74 | 104 |
75 | 105 |
76 function init_for_test() | 106 function init_for_test() |