http.request

From ComputerCraft Wiki
Revision as of 03:06, 3 July 2012 by Thesbros (Talk | contribs) (Add function layout + information)

Jump to: navigation, search


Grid Redstone.png  Function http.request
Sends a HTTP request to the website. Returns event "http_success" on success.
Syntax http.request()
Returns event "http_success" on success.
Part of ComputerCraft
API http

Examples

Grid paper.png  Example
Prints the code of a loading bar program if successful.
Code
http.request("http://pastebin.com/raw.php?i=Tk19jv43")
requesting = true
while requesting do
local event, url, sourceText = os.pullEvent()
if event == "http_success" then
respondedText = code.readAll()
print(respondedText)
requesting = false
else
print("Server didn't respond.")
requesting = false
end end