Last active
November 26, 2019 20:54
-
-
Save Kerollmops/6e65dfb16db1ddd4bd0555c3ca510007 to your computer and use it in GitHub Desktop.
wrk script that simulate user typing queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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