Mercurial Hosting > luan
comparison src/luan/modules/http/Http_test.luan @ 1153:1f4da56abd4f
change http cookies interface
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Feb 2018 20:01:23 -0700 |
parents | bae2d0c2576c |
children | 4beabb087be6 |
comparison
equal
deleted
inserted
replaced
1152:21d157b153fe | 1153:1f4da56abd4f |
---|---|
10 | 10 |
11 | 11 |
12 local Http_test = {} | 12 local Http_test = {} |
13 | 13 |
14 Http_test.welcome_file = "index.html" | 14 Http_test.welcome_file = "index.html" |
15 Http_test.cookie = {} | 15 Http_test.cookies = {} |
16 | 16 |
17 function Http_test.get_page(path) | 17 function Http_test.get_page(path) |
18 Http.request.path = path | 18 Http.request.path = path |
19 if Http_test.welcome_file ~= nil and matches(path,"/$") then | 19 if Http_test.welcome_file ~= nil and matches(path,"/$") then |
20 path = path .. Http_test.welcome_file | 20 path = path .. Http_test.welcome_file |
39 return Http_test.result.read_text() | 39 return Http_test.result.read_text() |
40 end | 40 end |
41 | 41 |
42 function Http_test.init() | 42 function Http_test.init() |
43 Http.request = Http.new_request{} | 43 Http.request = Http.new_request{} |
44 Http.request.cookie = Http_test.cookie | 44 Http.request.cookies = Http_test.cookies |
45 | 45 |
46 Http.response = Http.new_response{ | 46 Http.response = Http.new_response{ |
47 | 47 |
48 text_writer = function() | 48 text_writer = function() |
49 Http.sent_headers(Http.response.headers) | 49 Http.sent_headers(Http.response.headers) |
51 Http_test.text_writer = Http_test.result.text_writer() | 51 Http_test.text_writer = Http_test.result.text_writer() |
52 return Http_test.text_writer | 52 return Http_test.text_writer |
53 end | 53 end |
54 | 54 |
55 set_cookie = function(name,value) | 55 set_cookie = function(name,value) |
56 Http_test.cookie[name] = value | 56 Http_test.cookies[name] = value |
57 end | |
58 | |
59 set_persistent_cookie = function(name,value) | |
60 Http_test.cookies[name] = value | |
57 end | 61 end |
58 | 62 |
59 remove_cookie = function(name) | 63 remove_cookie = function(name) |
60 Http_test.cookie[name] = nil | 64 Http_test.cookies[name] = nil |
61 end | 65 end |
62 | 66 |
63 send_redirect = function(url) | 67 send_redirect = function(url) |
64 Http.response.redirect = url | 68 Http.response.redirect = url |
65 end | 69 end |