Skip to content

Instantly share code, notes, and snippets.

@Core-commits
Created October 17, 2020 21:50
Show Gist options
  • Save Core-commits/0eaaa00eac5e89e68631fedd72831675 to your computer and use it in GitHub Desktop.
Save Core-commits/0eaaa00eac5e89e68631fedd72831675 to your computer and use it in GitHub Desktop.
local http = require "socket.http"
local data = ""
local function collect(chunk)
if chunk ~= nil then
data = data .. chunk
end
return true
end
local ok, statusCode, headers, statusText = http.request {
method = "GET",
url = "http://someserver.sometld/somepath",
sink = collect
}
print("ok\t", ok);
print("statusCode", statusCode)
print("statusText", statusText)
print("headers:")
for i,v in pairs(headers) do
print("\t",i, v)
end
print("data", data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment