如何为apachebench添加http代理(ab)

ahu*_*igo 3 proxy apachebench

我想抓取ab发送或接收的HTTP数据包.

所以我在shell命令中添加了一个http_proxy:

$ export http_proxy=127.0.0.1:8888
Run Code Online (Sandbox Code Playgroud)

然后我执行ab命令:

$ ab -c 1 -n 1 http://localhost/
Run Code Online (Sandbox Code Playgroud)

最后,我的代理(127.0.0.1:8888)无法从ab获取http数据包.

有没有办法让ab通过http_proxy访问http?

这是我的环境:Mac OSX 10.10.3

ahu*_*igo 5

如果您阅读了有关ab的帮助ab -h,您会发现它支持代理选项-X:

-X proxy:port   Proxyserver and port number to use
Run Code Online (Sandbox Code Playgroud)

这个选项相当于curl's -x:

-x, --proxy [PROTOCOL://]HOST[:PORT]  Use proxy on given port
Run Code Online (Sandbox Code Playgroud)