blob: f7fb7f4e3fce778c593de7d720bad194866b1895 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
local connlisteners_register = require "net.connlisteners".register;
local new_request = require "net.httpserver".new_request;
local request_reader = require "net.httpserver".request_reader;
local requests = {}; -- Open requests
local httpserver = { default_port = 80, default_mode = "*a" };
function httpserver.listener(conn, data)
local request = requests[conn];
if not request then
request = new_request(conn);
requests[conn] = request;
end
if data then
request_reader(request, data);
end
end
function httpserver.disconnect(conn, err)
local request = requests[conn];
if request and not request.destroyed then
request.conn = nil;
request_reader(request, nil);
end
requests[conn] = nil;
end
connlisteners_register("httpserver", httpserver);
|