Software /
code /
prosody
Comparison
net/http/server.lua @ 4771:31a40da59308
net.http.server: Remove unused imports and variables (fixes traceback due to removed net.httpserver)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 28 Apr 2012 14:27:48 +0100 |
parent | 4740:bd9c8bc8036f |
child | 4787:1d753fecf95b |
comparison
equal
deleted
inserted
replaced
4770:1b17af95ce6f | 4771:31a40da59308 |
---|---|
10 local setmetatable = setmetatable; | 10 local setmetatable = setmetatable; |
11 local xpcall = xpcall; | 11 local xpcall = xpcall; |
12 local debug = debug; | 12 local debug = debug; |
13 local tostring = tostring; | 13 local tostring = tostring; |
14 local codes = require "net.http.codes"; | 14 local codes = require "net.http.codes"; |
15 local _G = _G; | |
16 local legacy_httpserver = require "net.httpserver"; | |
17 | 15 |
18 local _M = {}; | 16 local _M = {}; |
19 | 17 |
20 local sessions = {}; | 18 local sessions = {}; |
21 local listener = {}; | 19 local listener = {}; |
88 | 86 |
89 function listener.onconnect(conn) | 87 function listener.onconnect(conn) |
90 local secure = conn:ssl() and true or nil; | 88 local secure = conn:ssl() and true or nil; |
91 local pending = {}; | 89 local pending = {}; |
92 local waiting = false; | 90 local waiting = false; |
93 local function process_next(last_response) | 91 local function process_next() |
94 --if waiting then log("debug", "can't process_next, waiting"); return; end | 92 --if waiting then log("debug", "can't process_next, waiting"); return; end |
95 if sessions[conn] and #pending > 0 then | 93 if sessions[conn] and #pending > 0 then |
96 local request = t_remove(pending); | 94 local request = t_remove(pending); |
97 --log("debug", "process_next: %s", request.path); | 95 --log("debug", "process_next: %s", request.path); |
98 waiting = true; | 96 waiting = true; |
196 local payload = { request = request, response = response }; | 194 local payload = { request = request, response = response }; |
197 --log("debug", "Firing event: %s", event); | 195 --log("debug", "Firing event: %s", event); |
198 local result = events.fire_event(event, payload); | 196 local result = events.fire_event(event, payload); |
199 if result ~= nil then | 197 if result ~= nil then |
200 if result ~= true then | 198 if result ~= true then |
201 local code, body = 200, ""; | 199 local body = ""; |
202 local result_type = type(result); | 200 local result_type = type(result); |
203 if result_type == "number" then | 201 if result_type == "number" then |
204 response.status_code = result; | 202 response.status_code = result; |
205 if result >= 400 then | 203 if result >= 400 then |
206 body = events.fire_event("http-error", { code = result }); | 204 body = events.fire_event("http-error", { code = result }); |