0

我正在尝试将数据发布到 API。我每次都在构建请求。我正在向wrk.format()方法添加标题。尽管标题类型是字符串,但标题不接受事件。

headers = {}
s = {}
request = function() 

 headers["Authorization"] = "key"
 for name, value in pairs(headers) do
      s[1] = string.format("%s: %s", name, value)
 end
 print(s[1])
 print(type(s[1])
 return wrk.format("POST", "/api/", s[1] ,data)
end

抛出错误:

PANIC: unprotected error in call to Lua API ([string "wrk"]:0: attempt to index field 'headers' (a string value))

谁能帮我这个?

提前致谢。

4

0 回答 0