Software /
code /
prosody
Diff
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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/net/httpserver_listener.lua Mon Dec 22 22:12:11 2008 +0000 @@ -0,0 +1,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);