Changeset

2130:828e161cdfc7

net.httpserver, net.http: Update for new net.server API (untested)
author Matthew Wild <mwild1@gmail.com>
date Sun, 22 Nov 2009 04:44:26 +0000
parents 2129:fcdcdf00787c
children 2131:72411e239221
files net/http.lua net/httpserver.lua
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/net/http.lua	Sun Nov 22 04:43:46 2009 +0000
+++ b/net/http.lua	Sun Nov 22 04:44:26 2009 +0000
@@ -152,7 +152,7 @@
 	end
 	
 	req.handler, req.conn = server.wrapclient(socket.tcp(), req.host, req.port or 80, listener, "*a");
-	req.write = req.handler.write;
+	req.write = function (...) return req.handler:write(...); end
 	req.conn:settimeout(0);
 	local ok, err = req.conn:connect(req.host, req.port or 80);
 	if not ok and err ~= "timeout" then
@@ -200,7 +200,7 @@
 function destroy_request(request)
 	if request.conn then
 		request.handler.close()
-		listener.disconnect(request.conn, "closed");
+		listener.ondisconnect(request.conn, "closed");
 	end
 end
 
--- a/net/httpserver.lua	Sun Nov 22 04:43:46 2009 +0000
+++ b/net/httpserver.lua	Sun Nov 22 04:44:26 2009 +0000
@@ -209,7 +209,7 @@
 
 function new_request(handler)
 	return { handler = handler, conn = handler.socket, 
-			write = handler.write, state = "request", 
+			write = function (...) return handler:write(...); end, state = "request", 
 			server = http_servers[handler.serverport()],
 			send = send_response,
 			destroy = destroy_request,
@@ -230,7 +230,7 @@
 		end
 		request.handler.close()
 		if request.conn then
-			listener.disconnect(request.handler, "closed");
+			listener.ondisconnect(request.handler, "closed");
 		end
 	end
 end