giltene / wrk2

A constant throughput, correct latency recording variant of wrk
Apache License 2.0
4.28k stars 395 forks source link

URL's with underscores are considered invalid. #19

Open apenney opened 8 years ago

apenney commented 8 years ago

Hi,

I noticed today that URLs with underscores are seen as invalid:

» wrk2 -c 100 -s test.lua -H "x-openrtb-version: 2.2" "http://smadexeast.rubicon.endpoints.ntoggle.com:8000/supply-partners/rubicon" -R 1000 -d 10
Running 10s test @ http://smadexeast.rubicon.endpoints.ntoggle.com:8000/supply-partners/rubicon
  2 threads and 100 connections
^C  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    34.39ms   16.09ms 242.56ms   85.53%
    Req/Sec       -nan      -nan   0.00      0.00%
  4147 requests in 4.25s, 4.49MB read
Requests/sec:    975.63
Transfer/sec:      1.06MB
[I] apenney at arya in ~
» wrk2 -c 100 -s test.lua -H "x-openrtb-version: 2.2" "http://smadex_east.rubicon.endpoints.ntoggle.com:8000/supply-partners/rubicon" -R 1000 -d 10
invalid URL: http://smadex_east.rubicon.endpoints.ntoggle.com:8000/supply-partners/rubicon
Usage: wrk <options> <url>
  Options:
    -c, --connections <N>  Connections to keep open
    -d, --duration    <T>  Duration of test
    -t, --threads     <N>  Number of threads to use

    -s, --script      <S>  Load Lua script file
    -H, --header      <H>  Add header to request
    -L  --latency          Print latency statistics
    -U  --u_latency        Print uncorrceted latency statistics
        --timeout     <T>  Socket/request timeout
    -B, --batch_latency    Measure latency of whole
                           batches of pipelined ops
                           (as opposed to each op)
    -v, --version          Print version details
    -R, --rate        <T>  work rate (throughput)
                           in requests/sec (total)
                           [Required Parameter]

  Numeric arguments may include a SI unit (1k, 1M, 1G)
  Time arguments may include a time unit (2s, 2m, 2h)
[I] apenney at arya in ~
»

The httpparser.c code seems to allow 's so I'm not really sure where to start with fixing this. This was tested against master.

Fatahir commented 4 years ago

how did you fix this issue?

yukha-dw commented 2 years ago

If anyone needs the workaround, you can modify src/http_parser.h line 52 before compiling, change # define HTTP_PARSER_STRICT 1 to # define HTTP_PARSER_STRICT 0. The comment sounds like we can change it using parameter, but i don't know how. https://github.com/giltene/wrk2/blob/44a94c17d8e6a0bac8559b53da76848e430cb7a7/src/http_parser.h#L48-L53

Or just add || (c) == '_' in src/http_parser.c line 428 if you want to retain other strict rules. https://github.com/giltene/wrk2/blob/44a94c17d8e6a0bac8559b53da76848e430cb7a7/src/http_parser.c#L425-L435

Result: image