Difference between revisions of "Http failure (event)"
From ComputerCraft Wiki
(Created event page) |
(Added code example.) |
||
Line 3: | Line 3: | ||
{{Event | {{Event | ||
|name=http_failure | |name=http_failure | ||
− | |||
|return1=The URL to the website. | |return1=The URL to the website. | ||
+ | |desc=Fired when a call to [[http.request|http.request()]], [[http.get|http.get()]] or [[http.post|http.post()]] fails. | ||
+ | }} | ||
+ | {{Example | ||
+ | |desc=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 | ||
}} | }} |
Revision as of 17:33, 18 January 2013
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)) |
Event http_failure | |
Fired when a call to http.request(), http.get() or http.post() fails. | |
Returned Object 1 | The URL to the website. |
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 |