aboutsummaryrefslogtreecommitdiffstats
path: root/net/httpserver.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-01-21 14:53:01 +0000
committerMatthew Wild <mwild1@gmail.com>2010-01-21 14:53:01 +0000
commitc103c2bb6b528a64b032e55cfb97d0f41dbf695d (patch)
tree34d2238f5d3c6fa4e0758b3482e0e19e8f63ac6e /net/httpserver.lua
parente79181eab31b87bbab91ff2cc73f43d529d4b2dc (diff)
downloadprosody-c103c2bb6b528a64b032e55cfb97d0f41dbf695d.tar.gz
prosody-c103c2bb6b528a64b032e55cfb97d0f41dbf695d.zip
net.httpserver: More robust handling of headers split across multiple packets
Diffstat (limited to 'net/httpserver.lua')
-rw-r--r--net/httpserver.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/net/httpserver.lua b/net/httpserver.lua
index e16d4de6..c4be59bf 100644
--- a/net/httpserver.lua
+++ b/net/httpserver.lua
@@ -146,22 +146,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