如何执行POST

How to execute POST

使用 curl 我有:

$ curl -v -d "userName=user1&password=passwd1&language=en" http://myhost:23094/api/v2/authToken
...
> POST /api/v2/authToken HTTP/1.1
> User-Agent: curl/7.30.0
> Host: myhost:23094
> Accept: */*
> Content-Length: 39
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 39 out of 39 bytes
< HTTP/1.1 200 OK

我尝试使用以下查询构建 yandex tank 脚本:

我的load.ini:

[phantom]
address=my.ip.v4.here
port=8094
rps_schedule=line(1, 10, 1m)
ammo_type=uripost

我的ammo.txt

133 login
POST /api/v2/authToken HTTP/1.1
User-Agent: tank
Host: somemyhost.com
Content-Length: 39

userName=user1&password=passwd1&language=en

当我 运行 yandex-tank ammo.txt 时,我收到 400 Bad Request 错误。 在我看来,那个坦克不能使用 body 参数。如何让它使用它们?我做错了什么?

您的弹药不是 uripost 格式。根本不指定 ammo_type 它应该可以正常工作。如果您想使用 uripost 格式,请在 load.ini 中指定您的 headers 并在您的弹药文件中写入如下内容:

39 /api/v2/authToken login

userName=user1&password=passwd1&language=en

这里是uripost格式的description