How to send more than one query string in Apache Bench?

半世苍凉 提交于 2019-12-05 03:48:21

You probably just need to quote the URL to avoid shell special characters from being interpreted. In this case your & symbol is causing the text to the left to be run in the background while attempting to run superDo as a command.

 ab -n 1 -c 1 'http://localhost:2020/welTo.do?pxtId=3000007937&superDo=jack'
user551168

There are two workarounds for this:

  1. You can use double quote to surround the url:

ab -n 1 -c 1 "http://localhost:2020/welTo.do?pxtId=3000007937&superDo=jack"

  1. Escape "&" with a backslash:

ab -n 1 -c 1 http://localhost:2020/welTo.do?pxtId=3000007937\&superDo=jack

Have you tried the post file? think this should work:

ab -n 1 -c 1 -p postfile.txt -T 'application/x-www-form-urlencoded' http://localhost:2020/welTo.do

And then make a flat file named postfile.txt with contents like this:

pxtId=3000007937&superDo=jack

Example adapted from here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!