Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 不接受wrk.format格式的标题_Lua_Http Headers_Benchmarking_Wrk - Fatal编程技术网

Lua 不接受wrk.format格式的标题

Lua 不接受wrk.format格式的标题,lua,http-headers,benchmarking,wrk,Lua,Http Headers,Benchmarking,Wrk,我正在尝试将数据发布到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])

我正在尝试将数据发布到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))
有人能帮我吗


提前感谢。

第三个参数必须是表
标题
。您传递了一个字符串
s[1]
。正确示例:
wrk.format(“POST”、“/api/”、{[“Authorization”]=“key”},data)
如果我使用上述语法。甚至是投掷错误。错误参数#1到'len'(应为字符串,Get table))
wrk.format(..,..,body)
的第四个参数必须是字符串。您的
数据可能是一个表。