"Fossies" - the Fresh Open Source Software Archive

Member "wrk-4.2.0/scripts/counter.lua" (7 Feb 2021, 448 Bytes) of package /linux/www/wrk-4.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 -- example dynamic request script which demonstrates changing
    2 -- the request path and a header for each request
    3 -------------------------------------------------------------
    4 -- NOTE: each wrk thread has an independent Lua scripting
    5 -- context and thus there will be one counter per thread
    6 
    7 counter = 0
    8 
    9 request = function()
   10    path = "/" .. counter
   11    wrk.headers["X-Counter"] = counter
   12    counter = counter + 1
   13    return wrk.format(nil, path)
   14 end