http_success event

From ComputerCraft
Jump to: navigation, search
http_success
Event
Returns
  • url : string The URL of the request
  • handle : table A file-handle-like object that contains the contents of the request.

Source CC:Tweaked

Occurs when a HTTP request has completed successfully. Fired by a http.request call.

ExampleExampleRequest a page
Requests the example page and prints the result.
Code
-- Request the example page
http.request("https://example.computercraft.cc")
while true do
  -- Wait for a http_success event.
  local event, url, handle = os.pullEvent("http_success")
  -- If it's for our URL, then print the result.
  if url == "https://example.computercraft.cc" then
    print(handle.readAll())
    handle.close()
  end
end