Http success (event)

From ComputerCraft Wiki
Jump to: navigation, search


Grid Modem.png  Event http_success
Fired when a call to http.request completes successfully, and used internally in http.get and http.post.
Returned Object 1 The URL to the website
Returned Object 2 A handle that allows reading the response sent from the server


Grid paper.png  Example
Prints the response code from the server and the text returned from the server
Code
http.request( "http://www.example.com" )
event, url, handle = os.pullEvent( "http_success" )
print( "Got a response with the status code: "..handle.getResponseCode() )
print( "With the text: "..handle.readAll() )
handle:close()



Grid paper.png  Example
Prints all the available functions to call on the response from the server
Code
http.request( "http://www.example.com" )
while true do
  event, url, handle = os.pullEvent( "http_success" )
  for k, v in pairs( handle ) do
    print( k )
  end
end



Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox