http.checkURLAsync

From ComputerCraft
Jump to: navigation, search

http.checkURLAsync
Function
Syntax
http.checkURLAsync()
Returns boolean true | boolean false, string error
API http
Source CC:Tweaked (source)

An asynchronous version of http.checkURL. Determines whether a URL is valid and is whitelisted, meaning the HTTP API can connect to it.

ExampleExampleCheck whether a URL can be visited
Tests whether a remote and local URL is whitelisted
Code
local checkURL = "https://example.computercraft.cc/"
local ok, err = http.checkURLAsync(checkURL)
if not ok then 
  printError(err)
else
  while true do
    local event, url, ok, err = os.pullEvent("http_check")
    if url == checkURL then
      if not ok then printError(err) end
      break
    end
  end
end
Output Nothing, as long as https://example.com.computercraft.cc is whitelisted.