Apache Bench和POST数据 [英] Apache Bench and POST data

查看:301
本文介绍了Apache Bench和POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用apache bench在我的rails应用程序中负载测试一个create动作,但是ab似乎没有发送POST数据-尽管它确实正确提交了POST而不是GET请求.

i am trying to use apache bench to load test a create action in my rails application but ab doesn't appear to be sending the POST data - though it does correctly submit a POST and not a GET request.

这是我运行的命令:

ab -n 1 -p post -v 4 "http://oz01.zappos.net/registrations"

这是发布文件的内容:

authenticity_token=M18KXwSOuIVbDPZOVQy5h8aSGoU159V9S5uV2lpsAI0

rails日志显示有POST请求通过,但未显示任何要发布的参数:

the rails logs show a POST request coming through but don't show any parameters being posted:

Started POST "/registrations" for 10.66.210.70 at Thu Sep 09 17:48:06 -0700 2010
  Processing by RegistrationsController#create as */*
Rendered registrations/new.html.erb within layouts/application (14.0ms)
Completed 200 OK in 24ms (Views: 14.6ms | ActiveRecord: 0.1ms)

而来自浏览器的POST请求将导致此日志条目:

whereas a POST request coming from a browser results in this log entry:

Started POST "/registrations" for 192.168.66.20 at Thu Sep 09 17:49:47 -0700 2010
  Processing by RegistrationsController#create as HTML
  Parameters: {"submit"=>"true", "authenticity_token"=>"AfNG0UoTbJXnxke2725efhYAoi3ogddMC7Uqu5mAui0=", "utf8"=>"\342\234\223", "registration"=>{"city"=>"", "address"=>"", "name"=>"", "zip"=>"", "optin"=>"0", "state"=>"", "email"=>""}}
Rendered registrations/new.html.erb within layouts/application (13.7ms)
Completed 200 OK in 24ms (Views: 14.3ms | ActiveRecord: 0.1ms)

最后,这是ab为请求记录的内容:

and finally, this is what ab logs for the request:

---
POST /registrations HTTP/1.0
User-Agent: ApacheBench/2.0.40-dev
Host: oz01.zappos.net
Accept: */*
Content-length: 63
Content-type: text/plain


---

为什么不提取帖子数据?

why is it not picking up the post data?

如果"post"文件不存在,那么我会收到一条错误消息,提示它找不到文件,所以我至少知道它正在查找文件...

if the "post" file is not there then i get an error message saying it can't find the file so i know at very least it is finding the file...

推荐答案

也许您需要使用man ab中所述的-T选项:-

Maybe you need the -T option as stated in man ab:-

ab -n 1 -p post -v 4 -T application/x-www-form-urlencoded "http://oz01.zappos.net/registrations"

我在Django上进行了测试,看来Django并不真正在乎内容类型标头(无论我是否使用-T,它都会显示POSTed内容),但是Rails可能会想要它.

I tested with Django and it seem that Django don't really care about the content type header (it displayed the POSTed content whether I used -T or not) but Rails maybe want it.

这篇关于Apache Bench和POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆