Software / code / prosody
Comparison
net/httpserver.lua @ 1038:90f663769b75
net.httpserver: Fix potential nil access
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 22 Apr 2009 20:31:45 +0100 |
| parent | 958:172fb9a73017 |
| child | 1054:084d265b37cf |
comparison
equal
deleted
inserted
replaced
| 1037:cb5fdce8dcec | 1038:90f663769b75 |
|---|---|
| 6 local connlisteners_start = require "net.connlisteners".start; | 6 local connlisteners_start = require "net.connlisteners".start; |
| 7 local connlisteners_get = require "net.connlisteners".get; | 7 local connlisteners_get = require "net.connlisteners".get; |
| 8 local listener; | 8 local listener; |
| 9 | 9 |
| 10 local t_insert, t_concat = table.insert, table.concat; | 10 local t_insert, t_concat = table.insert, table.concat; |
| 11 local s_match, s_gmatch = string.match, string.gmatch; | 11 local s_match, s_gmatch, s_char = string.match, string.gmatch; |
| 12 local tonumber, tostring, pairs = tonumber, tostring, pairs; | 12 local tonumber, tostring, pairs = tonumber, tostring, pairs; |
| 13 | 13 |
| 14 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); | 14 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = s_char(tonumber("0x"..k)); return t[k]; end }); |
| 15 local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end | 15 local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end |
| 16 | 16 |
| 17 local log = require "util.logger".init("httpserver"); | 17 local log = require "util.logger".init("httpserver"); |
| 18 | 18 |
| 19 local http_servers = {}; | 19 local http_servers = {}; |