首先我们的json字符串直接放在文件postfile中
在我们使用json格式时,注意一定要将headers的Content_type设置为application/json,否则服务器端可能不能正确识别传送的body格式。
siege
经过测试的版本为3.02和3.04
siege POST请求:
尝试1:
siege -T 'application/json' -c 500 r 1 '10.23.54.151:19595/v1/db/nova/service_get_all POST <./postfile'
服务器端接收到body为postfile文件内容,但是content_type依旧是默认值“application/x-www-form-urlencoded”,致使服务器端不能正确处理。
尝试2:
siege -H 'Content-Type:application/json' -c 5