net/http.lua
changeset 7466 3b6e7ce9431f
parent 6826 3b07f38d70f5
child 7467 3b7de72e58a9
equal deleted inserted replaced
7464:72e48bddf617 7466:3b6e7ce9431f
    24 local log = require "util.logger".init("http");
    24 local log = require "util.logger".init("http");
    25 
    25 
    26 local _ENV = nil;
    26 local _ENV = nil;
    27 
    27 
    28 local requests = {}; -- Open requests
    28 local requests = {}; -- Open requests
       
    29 
       
    30 local function make_id(req) return (tostring(req):match("%x+$")); end
    29 
    31 
    30 local listener = { default_port = 80, default_mode = "*a" };
    32 local listener = { default_port = 80, default_mode = "*a" };
    31 
    33 
    32 function listener.onconnect(conn)
    34 function listener.onconnect(conn)
    33 	local req = requests[conn];
    35 	local req = requests[conn];
   122 	end
   124 	end
   123 
   125 
   124 	if not req.path then
   126 	if not req.path then
   125 		req.path = "/";
   127 		req.path = "/";
   126 	end
   128 	end
       
   129 
       
   130 	req.id = ex and ex.id or make_id(req);
   127 
   131 
   128 	local method, headers, body;
   132 	local method, headers, body;
   129 
   133 
   130 	local host, port = req.host, req.port;
   134 	local host, port = req.host, req.port;
   131 	local host_header = host;
   135 	local host_header = host;