HTTPie is a command-line HTTP client.
如果你经常需要通过终端以非交互模式访问网络服务器(例如,从网络上下载文件,或者是测试 RESTful 网络服务接口),可能你会选择的工具是 wget 或 curl。
HTTPie(读 aych-tee-tee-pie)是一款开源的命令行 HTTP 工具。HTTPie 采用 Python 开发,底层用到了 Requests 和 Pygments 库。HTTPie 设计用来增强 wget 和 curl 的可用性。它的主要目标是使通过命令行与网络服务器进行交互的过程变得尽可能的人性化。其提供了一个简单的 HTTP 环境来让我们通过简单而自然的语法发送任意 HTTP 请求,并显示彩色输出。HTTPie 可用于测试,调试和与 HTTP 服务器进行普通的交互。
$ http POST http://example.com/posts/3 \
Origin:example.com \ # : HTTP headers
name="John Doe" \ # = string
q=="search" \ # == URL parameters (?q=search)
age:=29 \ # := for non-strings
list:='[1,3,4]' \ # := json
file@file.bin \ # @ attach file
token=@token.txt \ # =@ read from file (text)
user:=@user.json # :=@ read from file (json)
$ http --form POST example.com \
name="John Smith" \
cv=@document.txt
一般快捷键我设置成 Ctrl+`,方便左手单手操作,下载地址:https://bbs.cdsy.xyz/thread-22899-1-1.html
$ echo 'data' | http example.org
$ cat | http POST example.com
<paste or typing>
^D
On OS X, you can send the contents of the clipboard with pbpaste:
$ pbpaste | http PUT example.com
