最近在测试数据,使用 POSTMAN 在 win 下面还挺好用的,Centos 下不知道能不能用,因为我的 Centos 是命令行没有图形界面,不知能否使用,或者有没有什么能在命令行下模拟 post 请求的工具。
postman 可以自动把请求参数转成各种编程语言的 HTTP 请求,包括 shell 命令
curl
newman?
直接用 curl
命令行就用 httpie 呗
HTTPie 比 curl 友好。
几个简单的例子:
```
$ http -v GET example.org
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: example.org
User-Agent: HTTPie/0.9.9
$ http -v --form PUT example.org param1=value1 param2=value2
PUT / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 27
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: example.org
User-Agent: HTTPie/0.9.9
param1=value1¶m2=value2
$ http -v PUT example.org param1=value1 param2=value2
PUT / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 40
Content-Type: application/json
Host: example.org
User-Agent: HTTPie/0.9.9
{
"param1": "value1",
"param2": "value2"
}
$ http -v PUT example.org User-Agent:Postman param1=value1 param2=value2
PUT / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 40
Content-Type: application/json
Host: example.org
User-Agent: Postman
{
"param1": "value1",
"param2": "value2"
}
```
HTTPie 的官网:
https://httpie.org/
postman 能直接生成 curl,其实感觉用 ipython 发 requests 更方便点
curl + 1
我一般请求都会通过 curl。
postman 很少用。
curl + jq . 简直不要太爽。
谢谢!学习了!
谢谢!学习了!
感谢!感谢!
httpie