Properly closing HTTP requests on errors in iterator.

This commit is contained in:
Florian Nücke 2014-06-10 18:15:21 +02:00
parent 644bb3e705
commit 29cbfb529e

View File

@ -38,10 +38,10 @@ function internet.request(url, data)
while true do
local data, reason = inet.read(handle.value)
if not data then
inet.close(handle.value)
if reason then
error(reason, 2)
else
inet.close(handle.value)
return nil -- eof
end
elseif #data > 0 then