github
HTTPie 是用 Python 编写,用到了 Requests 和 Pygments 这些出色的库。
主要特性:
Mac OS X
$ brew install httpie
Linux
# Debian-based distributions such as Ubuntu: $ apt-get install httpie # RPM-based distributions: $ yum install httpie
通过pip:
# Make sure we have an up-to-date version of pip and setuptools: $ pip install --upgrade pip setuptools $ pip install --upgrade httpie
使用
hello world
$ http httpie.org
http --help
参考手册
https://pypi.python.org/pypi/httpie
$ http PUT example.org X-API-Token:123 name=John
$ http -f POST example.org hello=World
$ http -v example.org
$ http -a USERNAME POST https://api.github.com/repos/jakubroztocil/httpie/issues/83/comments body='HTTPie is awesome!'
$ http example.org < file.json
$ http example.org/file > file
$ http --download example.org/file
$ http --session=logged-in -a username:password httpbin.org/get API-Key:123 $ http --session=logged-in httpbin.org/headers
$ http localhost:8000 Host:example.com
HTTP 请求方法位于 URL的左边,下面是使用DELETE方法进行请求
$ http DELETE example.org/todos/7
就像执行了下面的request-line命令行
DELETE /todos/7 HTTP/1.1
HTTPie 默认使用 GET (with no request data) 或者 POST (with request data).
HTTPie 需要请求一个URL. 默认的 scheme 是 http://, 而且可以省略参数 – http , example.org就代表了 http://example.org,此外,支持curl类似的localhost, 例如 :3000 代表 http://localhost:3000, 默认是80端口
$ http :/foo
GET /foo HTTP/1.1 Host: localhost
$ http :3000/bar
GET /bar HTTP/1.1 Host: localhost:3000
$ http :
GET / HTTP/1.1 Host: localhost
当手动在url中添加 querystring parameters , 可以直接使用 key==value key==value 的形式而不用担心 & 符号.
$ http GET www.google.com search==HTTPie tbm==isch
GET /?search=HTTPie&tbm=isch HTTP/1.1