【问题标题】:httperf to test an json rest apihttperf 测试一个 json rest api
【发布时间】:2012-11-27 16:39:24
【问题描述】:

我有一个包含以下内容的文件:

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

然后我运行这个命令:

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

但是服务器没有得到任何 json。我已经尝试了不同的转义选项,但没有成功。

在同一篇文章中使用 curl 可以完美运行。

你有什么用httperf发布json的指针吗?

提前致谢

【问题讨论】:

    标签: json rest httperf


    【解决方案1】:

    您必须在标题末尾添加显式回车,如下所示:

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

    【讨论】:

      【解决方案2】:

      带有标题、帖子和 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"
      

      创建包含以下内容的文件 (httprefpost_data.txt):

      /smartlog method=POST contents='data=testing&uid=13'
      

      【讨论】:

        【解决方案3】:

        使用以下内容将 URL 分解为服务器和 URI:

        httperf --print-reply --print-request --server "hostname.com" --uri="rest of url"

        【讨论】:

          猜你喜欢
          • 2012-12-06
          • 1970-01-01
          • 2018-10-21
          • 2018-08-30
          • 1970-01-01
          • 2019-08-06
          • 2021-06-04
          • 2014-04-28
          • 2014-12-31
          相关资源
          最近更新 更多