Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

httperf to test an json rest api

Tags:

json

rest

httperf

I have a file with this content:

helper?token=99999 method=POST contents='{"key1":99999, "key2":88888, "key3":55}'

and then I run this command:

httperf --print-reply --print-request --hog --client=0/1 --server=a_server --port=8080 --uri=/ --rate=25 --send-buffer=4096 --recv-buffer=16384 --add-header='Content-Type:application/json' --method=POST --wsesslog=1,1.000,entrada_carga

But the server is not getting any json. I already tried different escape options without success.

And the same post with curl it works perfectly.

Do you have any pointer in posting json with httperf?

thanks in advance

like image 306
user2427 Avatar asked Jan 15 '23 22:01

user2427


2 Answers

You have to add an explicit carriege return to the end of the header, like this:

--add-header='Content-Type:application/json\n'

like image 58
Sebastián Gun Avatar answered Jan 21 '23 18:01

Sebastián Gun


Example with header, post and ssl

httperf --server yourhost.com.com --uri /smartlog --num-conns=500 --rate=500 --ssl  --method POST --wsesslog=100000,0,httprefpost_data.txt --add-header "sdk:3.0\nconfig:3.0\nzid:0\n"

create file (httprefpost_data.txt) with below content:

/smartlog method=POST contents='data=testing&uid=13'
like image 35
Pankaj Chauhan Avatar answered Jan 21 '23 16:01

Pankaj Chauhan