This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mendax's profile picture

[HTTP] Table: Help?

Started by Mendax, 28 May 2012 - 07:08 PM
Mendax #1
Posted 28 May 2012 - 09:08 PM
So, I made a really nooby test code to try and work out how to use HTTP.

input = read()
print(http.get(input))
And all it comes up with is a message saying 'table:' and a bunch of numbers & letters.
Help?
Pinkishu #2
Posted 28 May 2012 - 09:11 PM
It has some methods like .readAll() which returns a string of the whole response and such

you coul try
for k,v in pairs(http.get(input)) do
  print(k.."=>"..v)
end
to get a method list i think
MysticT #3
Posted 28 May 2012 - 09:22 PM
http.get returns a handle to a (temporary) file containing the received text (the page's code normally).
To print all it's contents you can use:

local h = http.get("url")
if h then
  local s = h.readAll()
  h.close() -- not sure if really needed, but just in case
  print(s)
else
  print("Error connecting to url")
end