Comparison

net/httpserver_listener.lua @ 634:1af93ea23f96

Adding initial net.httpserver (lots of work to do on it)
author Matthew Wild <mwild1@gmail.com>
date Mon, 22 Dec 2008 22:12:11 +0000
child 1522:569d58d21612
comparison
equal deleted inserted replaced
633:fe1e01a06729 634:1af93ea23f96
1
2
3 local connlisteners_register = require "net.connlisteners".register;
4 local new_request = require "net.httpserver".new_request;
5 local request_reader = require "net.httpserver".request_reader;
6
7 local requests = {}; -- Open requests
8
9 local httpserver = { default_port = 80, default_mode = "*a" };
10
11 function httpserver.listener(conn, data)
12 local request = requests[conn];
13
14 if not request then
15 request = new_request(conn);
16 requests[conn] = request;
17 end
18
19 if data then
20 request_reader(request, data);
21 end
22 end
23
24 function httpserver.disconnect(conn, err)
25 local request = requests[conn];
26 if request and not request.destroyed then
27 request.conn = nil;
28 request_reader(request, nil);
29 end
30 requests[conn] = nil;
31 end
32
33 connlisteners_register("httpserver", httpserver);