How to change uri in request line in wrk

267 Views Asked by At

I'm trying to use wrk to send HTTP requests to our server. I'm trying to create a HTTP package, but looks at the wrk structure definition for lua, it doesn't seem like there's any way to set the uri in the request line. Does anyone know how its done? thanks.

1

There are 1 best solutions below

0
Staffier On

Not sure what you mean, exactly, but you can definitely set your path in the request function, e.g.:

names = { "Maverick", "Goose", "Viper", "Iceman", "Merlin", "Sundown", "Cougar", "Hollywood", "Wolfman", "Jester" }

request = function()
    wrk.method = "POST"
    wrk.path = "/test"   -- Is this what you're asking about?
    wrk.headers["Content-Type"] = "application/json"
    body = '{"name": ' .. names[math.random(#names)] .. '}'
    return wrk.format(nil, nil, nil, body)
end