Operating system for OpenComputers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
459B

  1. local tA = {...}
  2. local url = tA[1]
  3. local path = tA[2]
  4. local R=component.invoke(component.list("internet")(),"request",url)
  5. if not R then return false end
  6. local f=io.open(path,"wb")
  7. if not f then return false end
  8. repeat
  9. coroutine.yield()
  10. until R.finishConnect()
  11. local code, message, headers = R.response()
  12. if code > 299 or code < 200 then
  13. return false, code, message
  14. end
  15. repeat
  16. coroutine.yield()
  17. ns = R.read(2048)
  18. f:write(ns or "")
  19. until not ns
  20. f:close()