Mercurial Hosting > luan
comparison http/src/luan/modules/http/Http_test.luan @ 508:9218f9cf45d3
various fixes
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 May 2015 20:20:54 -0600 |
parents | 342964519194 |
children | 473e456444ff |
comparison
equal
deleted
inserted
replaced
507:40e18d335da9 | 508:9218f9cf45d3 |
---|---|
2 local Http = require "luan:http/Http" | 2 local Http = require "luan:http/Http" |
3 | 3 |
4 local M = {} | 4 local M = {} |
5 | 5 |
6 M.welcome_file = "index.html" | 6 M.welcome_file = "index.html" |
7 M.cookies = {} | 7 M.cookie = {} |
8 | 8 |
9 function M.get_page(path) | 9 function M.get_page(path) |
10 if M.welcome_file ~= nil and path.matches ".*/" then | 10 if M.welcome_file ~= nil and path.matches ".*/" then |
11 path = path .. M.welcome_file | 11 path = path .. M.welcome_file |
12 end | 12 end |
18 return M.result.read_text() | 18 return M.result.read_text() |
19 end | 19 end |
20 | 20 |
21 function M.init() | 21 function M.init() |
22 Http.request = Http.new_request{} | 22 Http.request = Http.new_request{} |
23 Http.request.cookies = M.cookies | 23 Http.request.cookie = M.cookie |
24 | 24 |
25 Http.response = Http.new_response{ | 25 Http.response = Http.new_response{ |
26 | 26 |
27 text_writer = function() | 27 text_writer = function() |
28 M.result = Io.uri "string:" | 28 M.result = Io.uri "string:" |
29 M.text_writer = M.result.text_writer() | 29 M.text_writer = M.result.text_writer() |
30 return M.text_writer | 30 return M.text_writer |
31 end; | 31 end; |
32 | 32 |
33 set_cookie = function(name,value) | 33 set_cookie = function(name,value) |
34 M.cookies[name] = value | 34 M.cookie[name] = value |
35 end; | 35 end; |
36 | 36 |
37 remove_cookie = function(name) | 37 remove_cookie = function(name) |
38 M.cookies[name] = nil | 38 M.cookie[name] = nil |
39 end; | 39 end; |
40 | 40 |
41 send_redirect = function(url) | 41 send_redirect = function(url) |
42 Http.response.redirect = url | 42 Http.response.redirect = url |
43 end; | 43 end; |