diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-02-19 02:59:00 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-02-19 02:59:00 +0000 |
commit | d8ecc06ff359005a10a309fb24c469ac0fd7a1c8 (patch) | |
tree | a8c85f2384772e77546b9a412eecc9da5baa1efe /net | |
parent | 13246c69e5e10fee84ccf57192817549266b7407 (diff) | |
parent | 73ce21ca9f4301e430675b894fab4805fcc0359b (diff) | |
download | prosody-d8ecc06ff359005a10a309fb24c469ac0fd7a1c8.tar.gz prosody-d8ecc06ff359005a10a309fb24c469ac0fd7a1c8.zip |
Merge with 0.7
Diffstat (limited to 'net')
-rw-r--r-- | net/http.lua | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/net/http.lua b/net/http.lua index 9b1954da..a5acf46d 100644 --- a/net/http.lua +++ b/net/http.lua @@ -73,22 +73,31 @@ local function request_reader(request, data, startpos) elseif request.state == "headers" then print("Reading headers...") local pos = startpos; - local headers = request.responseheaders or {}; + local headers, headers_complete = request.responseheaders; + if not headers then + headers = {}; + request.responseheaders = headers; + end for line in data:sub(startpos, -1):gmatch("(.-)\r\n") do startpos = startpos + #line + 2; local k, v = line:match("(%S+): (.+)"); if k and v then headers[k:lower()] = v; - print("Header: "..k:lower().." = "..v); + --print("Header: "..k:lower().." = "..v); elseif #line == 0 then - request.responseheaders = headers; + headers_complete = true; break; else print("Unhandled header line: "..line); end end + if not headers_complete then return; end -- Reached the end of the headers - request.state = "body"; + if not expectbody(request, request.code) then + request.callback(nil, request.code, request); + return; + end + request.state = "body"; if #data > startpos then return request_reader(request, data, startpos); end @@ -102,7 +111,7 @@ local function request_reader(request, data, startpos) request.code, request.responseversion = code, http; - if request.onlystatus or not expectbody(request, code) then + if request.onlystatus then if request.callback then request.callback(nil, code, request); end |