http.checkURLAsync

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

ExampleCheck whether a URL can be visited
Tests whether a remote and local URL is whitelisted
Code
<nowiki>
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
    </nowiki>
Output Nothing, as long as https://example.com.computercraft.cc is whitelisted.

http.checkURLAsync
Function
Syntax
http.checkURLAsync(
  • url : string
)

Returns boolean true | boolean false, string error
API http
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.