thread.addr - get or set the thread's server address thread:get(name) - get the value of a global in the thread's env thread:set(name, value) - set the value of a global in the thread's env thread:stop() - stop the thread
运行阶段
1 2 3 4
function init(args) function delay() function request() function response(status, headers, body)
wrk.format returns a HTTP request string containing the passed parameters merged with values from the wrk table. 根据参数和全局变量wrk,生成一个HTTP rquest string。
function wrk.lookup(host, service)
wrk.lookup returns a table containing all known addresses for the host and service pair. This corresponds to the POSIX getaddrinfo() function. 给定host和service(port/well known service name),返回所有可用的服务器地址信息。
function wrk.connect(addr)
wrk.connect returns true if the address can be connected to, otherwise it returns false. The address must be one returned from wrk.lookup(). 测试与给定的服务器地址信息是否可以成功创建连接
-- 拼装form-data form = "------WebKitFormBoundaryX3bY6PBMcxB1vCan\r\n" form = form .. "Content-Disposition: form-data; name="file"; filename="fake.jpg"\r\n" form = form .. "Content-Type: image/jpeg\r\n\r\n" form = form .. file:read("*a") form = form .. "\r\n------WebKitFormBoundaryX3bY6PBMcxB1vCan--"