codesenberg / bombardier

Fast cross-platform HTTP benchmarking tool written in Go
MIT License
6.03k stars 315 forks source link

Setting fastapi http method not working with additional headers #110

Open makubit opened 4 months ago

makubit commented 4 months ago

What version of bombardier are you using?

Current master (local build) -> 3ddcb83

It affects all of the architectures.

What did you do?

  1. Run the following command:
    ./bombardier-darwin-arm64 --connections=5 --requests=10 \
    --method=POST \
    --header="Content-Type: application/json" \
    --header="test: test" \
    --body-file="body.json" \
    http://some.service/
  2. You should see 4xx errors (actually it's 405) for the endpoints that don't implement GET.
    Done!
    Statistics        Avg      Stdev        Max
    Reqs/sec        13.38     103.84    1081.03
    Latency      684.46ms   774.50ms      2.20s
    HTTP codes:
    1xx - 0, 2xx - 0, 3xx - 0, 4xx - 10, 5xx - 0
    others - 0
    Throughput:     3.53KB/s

What you expected to happen?

Should return 2xx response code.

What actually happened?

In this commit there was moved part where we set method before copying additional headers. So, if we add some headers to the request, method is overwritten and it's always set to GET (that's why we see 405 response code on the endpoint that won't handle it). You can check this fork for resolving this mysterious issue :)