aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-03-03 22:05:05 +0000
committerMatthew Wild <mwild1@gmail.com>2010-03-03 22:05:05 +0000
commit8862e1b27eb767c99a068d13bd15c77c2c9e1471 (patch)
tree067f338a5f8e31a6b1fb6ca706562a044af80024 /net
parent87ff54c75266ffa37f716d1c7a542e956bbe54b3 (diff)
parent5d9b9b6b30f06a3e3aa957279357dd42ae19ddf4 (diff)
downloadprosody-8862e1b27eb767c99a068d13bd15c77c2c9e1471.tar.gz
prosody-8862e1b27eb767c99a068d13bd15c77c2c9e1471.zip
Merge 0.6.2/waqas with 0.6.2/MattJ
Diffstat (limited to 'net')
-rw-r--r--net/dns.lua9
-rw-r--r--net/httpserver.lua28
-rw-r--r--net/xmppclient_listener.lua1
-rw-r--r--net/xmppcomponent_listener.lua1
-rw-r--r--net/xmppserver_listener.lua1
5 files changed, 24 insertions, 16 deletions
diff --git a/net/dns.lua b/net/dns.lua
index ca0ec622..1b5321af 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -594,17 +594,18 @@ end
function resolver:remember(rr, type) -- - - - - - - - - - - - - - remember
--print ('remember', type, rr.class, rr.type, rr.name)
+ local qname, qtype, qclass = standardize(rr.name, rr.type, rr.class);
if type ~= '*' then
- type = rr.type;
- local all = get(self.cache, rr.class, '*', rr.name);
+ type = qtype;
+ local all = get(self.cache, qclass, '*', qname);
--print('remember all', all);
if all then append(all, rr); end
end
self.cache = self.cache or setmetatable({}, cache_metatable);
- local rrs = get(self.cache, rr.class, type, rr.name) or
- set(self.cache, rr.class, type, rr.name, setmetatable({}, rrs_metatable));
+ local rrs = get(self.cache, qclass, type, qname) or
+ set(self.cache, qclass, type, qname, setmetatable({}, rrs_metatable));
append(rrs, rr);
if type == 'MX' then self.unsorted[rrs] = true; end
diff --git a/net/httpserver.lua b/net/httpserver.lua
index dae49d2a..6bd641f9 100644
--- a/net/httpserver.lua
+++ b/net/httpserver.lua
@@ -36,8 +36,8 @@ end
local function send_response(request, response)
-- Write status line
local resp;
- if response.body then
- local body = tostring(response.body);
+ if response.body or response.headers then
+ local body = response.body and tostring(response.body);
log("debug", "Sending response to %s", request.id);
resp = { "HTTP/1.0 ", response.status or "200 OK", "\r\n"};
local h = response.headers;
@@ -49,14 +49,14 @@ local function send_response(request, response)
t_insert(resp, "\r\n");
end
end
- if not (h and h["Content-Length"]) then
+ if body and not (h and h["Content-Length"]) then
t_insert(resp, "Content-Length: ");
t_insert(resp, #body);
t_insert(resp, "\r\n");
end
t_insert(resp, "\r\n");
- if request.method ~= "HEAD" then
+ if body and request.method ~= "HEAD" then
t_insert(resp, body);
end
else
@@ -147,22 +147,29 @@ local function request_reader(request, data, startpos)
elseif request.state == "headers" then
log("debug", "Reading headers...")
local pos = startpos;
- local headers = request.headers or {};
+ local headers, headers_complete = request.headers;
+ if not headers then
+ headers = {};
+ request.headers = headers;
+ end
+
for line in data:gmatch("(.-)\r\n") do
startpos = (startpos or 1) + #line + 2;
local k, v = line:match("(%S+): (.+)");
if k and v then
headers[k:lower()] = v;
--- log("debug", "Header: "..k:lower().." = "..v);
+ --log("debug", "Header: '"..k:lower().."' = '"..v.."'");
elseif #line == 0 then
- request.headers = headers;
+ headers_complete = true;
break;
else
log("debug", "Unhandled header line: "..line);
end
end
- if not expectbody(request) then
+ if not headers_complete then return; end
+
+ if not expectbody(request) then
call_callback(request);
return;
end
@@ -176,7 +183,10 @@ local function request_reader(request, data, startpos)
log("debug", "Reading request line...")
local method, path, http, linelen = data:match("^(%S+) (%S+) HTTP/(%S+)\r\n()", startpos);
if not method then
- return call_callback(request, "invalid-status-line");
+ log("warn", "Invalid HTTP status line, telling callback then closing");
+ local ret = call_callback(request, "invalid-status-line");
+ request:destroy();
+ return ret;
end
request.method, request.path, request.httpversion = method, path, http;
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index 01d73a36..f455e7be 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -140,7 +140,6 @@ function xmppclient.disconnect(conn, err)
sm_destroy_session(session, err);
sessions[conn] = nil;
session = nil;
- collectgarbage("collect");
end
end
diff --git a/net/xmppcomponent_listener.lua b/net/xmppcomponent_listener.lua
index c16f41a0..2045d28f 100644
--- a/net/xmppcomponent_listener.lua
+++ b/net/xmppcomponent_listener.lua
@@ -169,7 +169,6 @@ function component_listener.disconnect(conn, err)
sessions[conn] = nil;
for k in pairs(session) do session[k] = nil; end
session = nil;
- collectgarbage("collect");
end
end
diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua
index 4394eac5..86a3d735 100644
--- a/net/xmppserver_listener.lua
+++ b/net/xmppserver_listener.lua
@@ -162,7 +162,6 @@ function xmppserver.disconnect(conn, err)
s2s_destroy_session(session, err);
sessions[conn] = nil;
session = nil;
- collectgarbage("collect");
end
end