# HG changeset patch # User Matthew Wild # Date 1231902386 0 # Node ID ab3c47f4fe1d02ea994d2a87811275dab4cee475 # Parent 2afd6d9e21cd793df164cd00eda04b0deb3fd2ad net.http: Fix for callbacks being triggered multiple times for the same request diff -r 2afd6d9e21cd -r ab3c47f4fe1d net/http.lua --- a/net/http.lua Tue Jan 13 23:16:39 2009 +0500 +++ b/net/http.lua Wed Jan 14 03:06:26 2009 +0000 @@ -37,9 +37,11 @@ request.callback("connection-closed", 0, request); end destroy_request(request); + request.body = nil; + request.state = "completed"; return; end - if request.state == "body" then + if request.state == "body" and request.state ~= "completed" then print("Reading body...") if not request.body then request.body = {}; request.havebodylength, request.bodylength = 0, tonumber(request.responseheaders["content-length"]); end if startpos then