I don't see why you can't use PiL advice or copas library (this is almost the same answer as is given here).
Copas wraps the socket interface (not socket.http
), but you can use low level interface to get what you need with something like this (not tested):
require("socket")
local conn = socket.tcp()
conn:connect("ipv4.download.thinkbroadband.com", 80)
conn:send("GET /5MB.zip HTTP/1.1\n\n")
local file, err = conn:receive()
print(err or file)
conn:close()
You can then use addthread
from copas to give you a non-blocking socket and use step/loop
functions to do receive
while there is something to receive.
Using copas is less work, while using settimeout(0)
directly gives you more control.