Purpose:
- 在命令行界面确实需要一款网络工具,但是curl太难用了, 要记忆的参数符号太多了。
- 相比于curl这个工具的突出特点是命令看上去更加的人性化, 而且有语法高亮
Feelings:
- 相比于curl命令上的变化还挺多的
- 而且更加的直观,用官方的话说就是intuitive
- 简单的json使用非常的方便
Notes:
- 官方网站
- 命令行命令是http
- http method:
- httpie支持restful风格的请求
- ❌如果请求中没有数据就自动发get请求, 如果有就发post请求—这个没实践的时候发现不太对,都发的get请求
- 如果是其他method,可以按如下方式使用,很类似于http的请求格式:
http DELETE example.org/todos/7
- Request URL
- 对localhost有特别的shortcuts,可以省略前面的localhost这个字符串
http :8080/foo
## 以下是回复
GET /foo HTTP/1.1
Host: localhost
- 可以给https一个别名,方便使用
alias https='http --default-scheme=https'
-
Request Items:通过分隔符去区分各种类型的item,而不是参数选项
request items - JSON, 使用很简洁:
➜ ~ http POST :8080/jsonTest name="kk" age=123
# 以下是回复
HTTP/1.1 200
Content-Length: 34
Content-Type: application/json;charset=UTF-8
Date: Fri, 09 Nov 2018 03:38:31 GMT
server_v_{"name":"kk","age":"123"}
- Follow Location :To instruct HTTPie to follow the Location header of 30x responses and show the final response instead, use the --follow, -F option:
$ http --follow httpbin.org/redirect/3
- Download, 像wget一样简单,很实用, 另外下载的时候可以使用 > 来重定向文件
http --download https://github.com/jakubroztocil/httpie/archive/master.tar.gz
- Resuming downloads :If --output, -o is specified, you can resume a partial download using the --continue, -c option. This only works with servers that support Range requests and 206 Partial Content responses. If the server doesn't support that, the whole file will simply be downloaded:
$ http -dco file.zip example.org/file
ps: 涉及到localhost的用例需要自己搭建本地服务