Skip to content

Instantly share code, notes, and snippets.

@Kerollmops
Last active November 26, 2019 20:54
Show Gist options
  • Select an option

  • Save Kerollmops/6e65dfb16db1ddd4bd0555c3ca510007 to your computer and use it in GitHub Desktop.

Select an option

Save Kerollmops/6e65dfb16db1ddd4bd0555c3ca510007 to your computer and use it in GitHub Desktop.
wrk script that simulate user typing queries
full_query = "I love paris and new york with my friends "
length = 1
local char_to_hex = function(c)
return string.format("%%%02X", string.byte(c))
end
local function urlencode(url)
if url == nil then
return
end
url = url:gsub("\n", "\r\n")
url = url:gsub("([^%w ])", char_to_hex)
url = url:gsub(" ", "+")
return url
end
request = function()
path = "/native-functions/search-big-wat?q=" .. urlencode(string.sub(full_query, 1, length))
length = (length % string.len(full_query)) + 1
return wrk.format(nil, path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment