5 -- This project is MIT/X11 licensed. Please see the |
5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. |
6 -- COPYING file in the source package for more information. |
7 -- |
7 -- |
8 |
8 |
9 |
9 |
10 local socket = require "socket" |
|
11 local server = require "net.server" |
10 local server = require "net.server" |
12 local url_parse = require "socket.url".parse; |
11 local url_parse = require "socket.url".parse; |
13 local httpstream_new = require "util.httpstream".new; |
12 local httpstream_new = require "util.httpstream".new; |
14 |
13 |
15 local connlisteners_start = require "net.connlisteners".start; |
14 local connlisteners_start = require "net.connlisteners".start; |
16 local connlisteners_get = require "net.connlisteners".get; |
15 local connlisteners_get = require "net.connlisteners".get; |
17 local listener; |
16 local listener; |
18 |
17 |
19 local t_insert, t_concat = table.insert, table.concat; |
18 local t_insert, t_concat = table.insert, table.concat; |
20 local s_match, s_gmatch = string.match, string.gmatch; |
|
21 local tonumber, tostring, pairs, ipairs, type = tonumber, tostring, pairs, ipairs, type; |
19 local tonumber, tostring, pairs, ipairs, type = tonumber, tostring, pairs, ipairs, type; |
22 |
20 |
23 local urlencode = function (s) return s and (s:gsub("%W", function (c) return ("%%%02x"):format(c:byte()); end)); end |
21 local urlencode = function (s) return s and (s:gsub("%W", function (c) return ("%%%02x"):format(c:byte()); end)); end |
24 |
22 |
25 local log = require "util.logger".init("httpserver"); |
23 local log = require "util.logger".init("httpserver"); |