Advertisement
Guest User

itest.lua

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