我正在尝试通过 LUA 调用 REST API。但是,我无法捕获 API 返回的完整原始响应。下面是代码示例:
local http_socket = require("socket.http")
local pretty_print = require("pl.pretty")
local header = {
["x-device-type"] = "M",
["authorization"] = "ashdjkashd",
["x-app-secret"] = "asdasda",
["x-user-id"] = "asdasdasd"
}
r, c, h = http_socket.request {
method = "GET", -- Validation API Method
url = "http://google.com", -- Validation API URL
headers = header
}
print(r .. c)
pretty_print.dump(h)
我正在使用 lua 5.3,并且 luarocks 版本=2.4.1。在变量 ci 中获取代码,在 h 中有一些标题。我需要捕获 API 返回的完整响应。