diff options
Diffstat (limited to 'net/http.lua')
-rw-r--r-- | net/http.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/http.lua b/net/http.lua index 38db0c0d..64d83948 100644 --- a/net/http.lua +++ b/net/http.lua @@ -27,8 +27,9 @@ end local function request_reader(request, data, startpos) if not data then if request.body then + log("debug", "Connection closed, but we have data, calling callback..."); request.callback(t_concat(request.body), request.code, request); - else + elseif request.state ~= "completed" then -- Error.. connection was closed prematurely request.callback("connection-closed", 0, request); end @@ -46,11 +47,15 @@ local function request_reader(request, data, startpos) request.havebodylength = request.havebodylength + #data; if request.havebodylength >= request.bodylength then -- We have the body + log("debug", "Have full body, calling callback"); if request.callback then request.callback(t_concat(request.body), request.code, request); end + request.body = nil; + request.state = "completed"; + else + print("", "Have "..request.havebodylength.." bytes out of "..request.bodylength); end - print("", "Have "..request.havebodylength.." bytes out of "..request.bodylength); end elseif request.state == "headers" then print("Reading headers...") |