how to specify query string in url with apache bench
Asked Answered
C

3

13

My rails application is running on thin server which i want to benchmark using apachebench

the command am using is

ab -n 1 -c 1 http://localhost:3001/welcome/search?query="doctor"&rad=5

But thin server is not taking this url.Its giving

!! Invalid Request

Can any one help me how to give the url such that thin accepts the url with query string

Cockerham answered 9/5, 2010 at 12:1 Comment(0)
T
29

apache benchmark wont resolve "localhost" out of the url. change it to 0.0.0.0 or 127.0.0.1 and quote the whole url to avoid problems with the ampersand. eg:

ab -n 1 -c 1 "http://0.0.0.0:3001/welcome/search?query=doctor&rad=5"
Tychonn answered 2/5, 2011 at 18:33 Comment(0)
K
5

Your query string is not properly encoded. Remove the double quote. If it's needed, you need to send it like this,

ab -n 1 -c 1 http://localhost:3001/welcome/search?query=%22doctor%22&rad=5
Kizzee answered 9/5, 2010 at 12:51 Comment(4)
yeah you were right.I removed double quote so Invalid request is resolved. NOw suppose my query is localhost:3001/welcome/… ,medical is taken but college is not considered, value 5 of rad is not taken by thin; i even tried with substituting & with %26 it didnt work.Cockerham
& is interpredet as a shell parameter. You can put the whole URL in quotes and it will work: ab -n 1 -c 1 "http://localhost:3001/welcome/search?query=%22doctor%22&rad=5"Accuse
Apparently this doesn't work with ApacheBench2. I am trying the following: ab2 -n 8000 -c 100 "xxx.xx.xxx.xx:8000?jsonp=callbackFunction&articeUrl=http%3A…" Getting an "invalid URL" error!Midyear
as pointed out the problem is the ampersand, the other answer (using double quotes around the url) works.Preferable
B
3

This was not working for me, though this line did work:

ab -n 1 -c 1 -B 127.0.0.1 "http://localhost:3001/some/stuff"

Mind the casing!

Bernhard answered 16/7, 2012 at 11:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.