Http failure (event)

From ComputerCraft Wiki
Revision as of 17:33, 18 January 2013 by TheOriginalBIT (Talk | contribs) (Added code example.)

Jump to: navigation, search
This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: A demonstration on the use and handling of this event would be beneficial. AfterLifeLochie 15:53, 30 November 2012 (MSK))



Grid Modem.png  Event http_failure
Fired when a call to http.request(), http.get() or http.post() fails.
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