mirror of
https://github.com/bjc/prosody.git
synced 2025-04-06 22:57:38 +03:00
net.httpserver: More robust handling of headers split across multiple packets
This commit is contained in:
parent
e79181eab3
commit
c103c2bb6b
1 changed files with 11 additions and 4 deletions
|
@ -146,21 +146,28 @@ local function request_reader(request, data, startpos)
|
||||||
elseif request.state == "headers" then
|
elseif request.state == "headers" then
|
||||||
log("debug", "Reading headers...")
|
log("debug", "Reading headers...")
|
||||||
local pos = startpos;
|
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
|
for line in data:gmatch("(.-)\r\n") do
|
||||||
startpos = (startpos or 1) + #line + 2;
|
startpos = (startpos or 1) + #line + 2;
|
||||||
local k, v = line:match("(%S+): (.+)");
|
local k, v = line:match("(%S+): (.+)");
|
||||||
if k and v then
|
if k and v then
|
||||||
headers[k:lower()] = v;
|
headers[k:lower()] = v;
|
||||||
-- log("debug", "Header: "..k:lower().." = "..v);
|
--log("debug", "Header: '"..k:lower().."' = '"..v.."'");
|
||||||
elseif #line == 0 then
|
elseif #line == 0 then
|
||||||
request.headers = headers;
|
headers_complete = true;
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
log("debug", "Unhandled header line: "..line);
|
log("debug", "Unhandled header line: "..line);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not headers_complete then return; end
|
||||||
|
|
||||||
if not expectbody(request) then
|
if not expectbody(request) then
|
||||||
call_callback(request);
|
call_callback(request);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue