Advertisement
Win4Win

Google Test

Nov 26th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. local term = require("term")
  2. while true do
  3. term.clear()
  4.  
  5. local inspect = require("inspect")
  6. local internet = require("internet")
  7.  
  8. local handle = internet.request("https://www.google.com")
  9. local result = ""
  10. for chunk in handle do result = result..chunk end
  11. -- Print the body of the HTTP response
  12. -- print(result)
  13.  
  14. -- Grab the metatable for the handle. This contains the
  15. -- internal HTTPRequest object.
  16. local mt = getmetatable(handle)
  17.  
  18. -- The response method grabs the information for
  19. -- the HTTP response code, the response message, and the
  20. -- response headers.
  21. local code, message, headers = mt.__index.response()
  22. print("code = "..tostring(code))
  23. print("message = "..tostring(message))
  24. print(inspect(headers))
  25.  
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement