Http failure (event)

From ComputerCraft Wiki
Revision as of 23:05, 5 May 2013 by Hawk777 (Talk | contribs) (Trim a bit, clarify description)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Grid Modem.png  Event http_failure
Fired when a call to http.request fails, and used internally in http.get and http.post.
Returned Object 1 The URL to the website


Grid paper.png  Example
Prints a message and quits when the requested URL could not be contacted.
Code
http.request( "http://www.example-failure.com" )
while true do
  event, url = os.pullEvent()
  if event == "http_failure" then
    print( "Cannot contact the server: "..url )
    break
  end
end