5

I have an Apache Bench POST test command like: ab -p test.json -n 1000 -c 100 -T "application/json" "http://localhost:8080/test"

However, my test.json is very simple, e.g.: {"foo": 1}

Is it possible to read that in directly to the ab command, without a file reference? Something like: ab -p '{"foo": 1}' -n 1000 -c 100 -T "application/json" "http://localhost:8080/test"

(I know that doesn't work, just wondering if there is a good linux file mimic trick or something)

My only workaround currently is: echo '{"foo": 1}' > test.json && ab -p test.json -n 1000 -c 100 -T "application/json" "http://localhost:8080/test" && rm test.json

But I find that a bit too clunky.

1 Answer 1

6

Try:

cat test.json | ab -p /dev/stdin -n 1000 -c 100 -T "application/json" "http://localhost:8080/test"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.