annotate http/src/luan/modules/http/Http.luan @ 499:fa4af530697f

add http/dump
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 18 May 2015 14:24:50 -0600
parents ee55be414a34
children ab9c2afefb47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
498
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
1 java()
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
2 local Luan = require "luan:Luan"
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
3 local ipairs = Luan.ipairs
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
4 local pairs = Luan.pairs
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
5 local set_metatable = Luan.set_metatable
458
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
6 local Io = require "luan:Io"
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
7 local Html = require "luan:Html"
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
8 local url_encode = Html.url_encode
498
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
9 local HttpServicer = require "java:luan.modules.http.HttpServicer"
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
10 local IoLuan = require "java:luan.modules.IoLuan"
320
fed1893821bf remove global namespace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 300
diff changeset
11
fed1893821bf remove global namespace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 300
diff changeset
12
499
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
13 to_header_name = HttpServicer.toHeaderName
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
14
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
15
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
16 local singular_metatable = {}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
17
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
18 function singular_metatable.__index(table,key)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
19 local list = table.__plural[key]
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
20 return list and list[1]
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
21 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
22
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
23 function singular_metatable.__new_index(table,key,value)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
24 table.__plural[key] = {value}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
25 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
26
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
27 function singular_metatable.__pairs(table)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
28 local iter = pairs(table.__plural)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
29 return function()
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
30 local key, value = iter()
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
31 return key, value and value[1]
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
32 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
33 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
34
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
35
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
36 local function new_common(this)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
37 this = this or {}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
38 this.headers = {}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
39 this.header = {__plural=this.headers}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
40 set_metatable(this.header,singular_metatable)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
41 return this
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
42 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
43
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
44
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
45 function new_request(this)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
46 this = new_common(this)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
47 this.method = "GET" -- default
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
48 -- this.path
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
49 -- this.protocol
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
50 this.scheme = "http" -- default
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
51 this.parameters = {}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
52 this.parameter = {__plural=this.parameters}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
53 set_metatable(this.parameter,singular_metatable)
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
54 this.cookie = {}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
55
499
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
56 function this.query_string()
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
57 local string_uri = Io.uri "string:"
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
58 local out = string_uri.text_writer()
499
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
59 local and_char = ""
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
60 for name, values in pairs(this.parameters) do
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
61 for _, value in ipairs(values) do
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
62 out.write( and_char, url_encode(name), "=", url_encode(value) )
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
63 and_char = "&"
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
64 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
65 end
499
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
66 out.close()
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
67 local s = string_uri.read_text()
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
68 return s == "" and nil or s
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
69 end
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
70
499
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
71 function this.url()
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
72 local url = this.scheme.."://"..this.header.host..this.path
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
73 if this.method ~= "POST" then
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
74 local query = this.query_string()
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
75 if query ~= nil then
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
76 url = url.."?"..query
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
77 end
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
78 end
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
79 return url
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
80 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
81
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
82 return this
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
83 end
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
84
498
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
85 STATUS = {
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
86 OK = 200;
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
87 -- add more as needed
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
88 }
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
89
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
90 function new_response(this)
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
91 this = new_common(this)
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
92 this.status = STATUS.OK
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
93 if this.java ~= nil then
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
94 this.send_redirect = this.java.sendRedirect
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
95 this.send_error = this.java.sendError
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
96
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
97 function this.set_cookie(name,value,is_persistent,domain)
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
98 HttpServicer.setCookie(this.java,response.java,name,value,is_persistent,domain)
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
99 end
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
100
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
101 function this.remove_cookie(name,domain)
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
102 HttpServicer.removeCookie(this.java,response.java,name,domain)
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
103 end
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
104
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
105 function this.text_writer()
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
106 return IoLuan.textWriter(this.java.getWriter())
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
107 end
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
108 end
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
109 return this
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
110 end
ee55be414a34 Http.response is now mostly luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
111
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
112 -- request = new_request{} -- filled in by HttpServicer
499
fa4af530697f add http/dump
Franklin Schmidt <fschmidt@gmail.com>
parents: 498
diff changeset
113 -- response = new_response{} -- filled in by HttpServicer
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
114
251
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
115
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
116
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
117 function init_for_test()
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
118
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
119 test = test or {}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
120
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
121 test.welcome_file = "index.html"
463
895afcd2b281 improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 458
diff changeset
122
895afcd2b281 improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 458
diff changeset
123 function get_page(path)
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
124 if test.welcome_file ~= nil and path.matches ".*/" then
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
125 path = path .. test.welcome_file
463
895afcd2b281 improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 458
diff changeset
126 end
458
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
127 local old_out = Io.stdout
463
895afcd2b281 improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 458
diff changeset
128 local mod = require("site:"..path)
495
598123096772 rename service() to respond()
Franklin Schmidt <fschmidt@gmail.com>
parents: 494
diff changeset
129 mod.respond()
458
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
130 text_writer.close()
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
131 Io.stdout = old_out
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
132 return result.read_text()
251
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
133 end
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
134
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
135 test.cookies = test.cookies or {}
252
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
136
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
137 request = new_request{}
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
138 request.cookies = test.cookies
251
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
139
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
140 response = {
252
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
141
251
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
142 text_writer = function()
458
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
143 result = Io.uri "string:"
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
144 text_writer = result.text_writer()
507c0af598ba improve Http.init_for_test
Franklin Schmidt <fschmidt@gmail.com>
parents: 377
diff changeset
145 return text_writer
251
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
146 end;
252
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
147
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
148 set_cookie = function(name,value)
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
149 test.cookies[name] = value
252
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
150 end;
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
151
253
dddf4e85bfe4 finish basic web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 252
diff changeset
152 remove_cookie = function(name)
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
153 test.cookies[name] = nil
253
dddf4e85bfe4 finish basic web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 252
diff changeset
154 end;
dddf4e85bfe4 finish basic web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 252
diff changeset
155
252
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
156 send_redirect = function(url)
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
157 response.redirect = url
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
158 end;
3896138955b1 web testing...
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 251
diff changeset
159
266
4dca283b9b74 add Http.response.headers for testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 264
diff changeset
160 headers = {};
4dca283b9b74 add Http.response.headers for testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 264
diff changeset
161
251
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
162 }
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
163
705d14f4d8ee start web testing
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
164 end