forked from izaya/OC-PsychOS2
attempt to force the internet card to work (ha\!)
This commit is contained in:
parent
360bb88ac3
commit
4e3df481cc
@ -67,7 +67,6 @@ end
|
|||||||
|
|
||||||
function dl.protos.http(host, optPort, path, dest, url) -- string string string number -- boolean -- Downloads *url* to *dest* via the internet card, if available.
|
function dl.protos.http(host, optPort, path, dest, url) -- string string string number -- boolean -- Downloads *url* to *dest* via the internet card, if available.
|
||||||
if not component.list("internet")() then
|
if not component.list("internet")() then
|
||||||
print("Internet card unavailable, falling back to proxy.")
|
|
||||||
local proto,host,sPort,path = parseURL(url)
|
local proto,host,sPort,path = parseURL(url)
|
||||||
local proxy = os.getenv(proto:upper().."_PROXY")
|
local proxy = os.getenv(proto:upper().."_PROXY")
|
||||||
if not proxy and fs.exists("/boot/cfg/"..proto.."_proxy") then
|
if not proxy and fs.exists("/boot/cfg/"..proto.."_proxy") then
|
||||||
@ -76,7 +75,7 @@ function dl.protos.http(host, optPort, path, dest, url) -- string string string
|
|||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
if not proxy then error("No internet card or HTTP(S) proxy available") end
|
if not proxy then error("No internet card or HTTP(S) proxy available") end
|
||||||
print("Proxy found: "..proxy)
|
print("Internet card unavailable, falling back to proxy "..proxy)
|
||||||
if optPort then host=string.format("%s:%i",host,optPort) end
|
if optPort then host=string.format("%s:%i",host,optPort) end
|
||||||
return dl.wget(string.format("%s/%s%s",proxy,host,path),dest)
|
return dl.wget(string.format("%s/%s%s",proxy,host,path),dest)
|
||||||
end
|
end
|
||||||
@ -88,7 +87,11 @@ function dl.protos.http(host, optPort, path, dest, url) -- string string string
|
|||||||
repeat
|
repeat
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
until R.finishConnect()
|
until R.finishConnect()
|
||||||
local code, message, headers = R.response()
|
local code, messsage, headers
|
||||||
|
repeat
|
||||||
|
coroutine.yield()
|
||||||
|
code, message, headers = R.response()
|
||||||
|
until code or message
|
||||||
if code > 299 or code < 200 then
|
if code > 299 or code < 200 then
|
||||||
return false, code, message
|
return false, code, message
|
||||||
end
|
end
|
||||||
@ -97,7 +100,7 @@ function dl.protos.http(host, optPort, path, dest, url) -- string string string
|
|||||||
io.write(string.format("Saving %s to %s...\n", url, dest))
|
io.write(string.format("Saving %s to %s...\n", url, dest))
|
||||||
repeat
|
repeat
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
ns = R.read(2048)
|
ns = R.read()
|
||||||
f:write(ns or "")
|
f:write(ns or "")
|
||||||
until not ns
|
until not ns
|
||||||
f:close()
|
f:close()
|
||||||
|
Loading…
Reference in New Issue
Block a user