Software /
code /
prosody
Comparison
net/http.lua @ 714:ab3c47f4fe1d
net.http: Fix for callbacks being triggered multiple times for the same request
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 14 Jan 2009 03:06:26 +0000 |
parent | 678:1859edec2237 |
child | 719:b1eb112478b8 |
comparison
equal
deleted
inserted
replaced
713:2afd6d9e21cd | 714:ab3c47f4fe1d |
---|---|
35 elseif request.state ~= "completed" then | 35 elseif request.state ~= "completed" then |
36 -- Error.. connection was closed prematurely | 36 -- Error.. connection was closed prematurely |
37 request.callback("connection-closed", 0, request); | 37 request.callback("connection-closed", 0, request); |
38 end | 38 end |
39 destroy_request(request); | 39 destroy_request(request); |
40 request.body = nil; | |
41 request.state = "completed"; | |
40 return; | 42 return; |
41 end | 43 end |
42 if request.state == "body" then | 44 if request.state == "body" and request.state ~= "completed" then |
43 print("Reading body...") | 45 print("Reading body...") |
44 if not request.body then request.body = {}; request.havebodylength, request.bodylength = 0, tonumber(request.responseheaders["content-length"]); end | 46 if not request.body then request.body = {}; request.havebodylength, request.bodylength = 0, tonumber(request.responseheaders["content-length"]); end |
45 if startpos then | 47 if startpos then |
46 data = data:sub(startpos, -1) | 48 data = data:sub(startpos, -1) |
47 end | 49 end |