7.httpie

2022-12-03

可以使用curl或httpie测试我们的服务器。Httpie是用Python编写的用户友好的http客户端
 
安装:pip3 install httpie

#get请求示例
输入命令:http http://127.0.0.1:8000/snippets/ 结果如下:
HTTP/1.1 200 OK
Content-Length: 354
Content-Type: application/json
Date: Sun, 28 Apr 2019 02:53:42 GMT
Server: WSGIServer/0.2 CPython/3.7.3
X-Frame-Options: SAMEORIGIN
[ { "code": "foo = \"bar\"\n", "id": 1, "language": "python", "linenos": false, "style": "friendly", "title": "" }]

# post请求
http --json POST http http://127.0.0.1:8000/snippets/ #debug模式
http --json POST --debug http http://127.0.0.1:8000/snippets/ #认证
http -a user:password http http://127.0.0.1:8000/snippets/

7.httpie的相关教程结束。

《7.httpie.doc》

下载本文的Word格式文档,以方便收藏与打印。