Skip to content

Instantly share code, notes, and snippets.

@scr1p7ed scr1p7ed/request.lua
Created Nov 16, 2015

Embed
What would you like to do?
sample lua http get
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
You can’t perform that action at this time.