Purpose:
- 在命令行界面確實需要一款網(wǎng)絡(luò)工具若厚,但是curl太難用了, 要記憶的參數(shù)符號太多了讥邻。
- 相比于curl這個工具的突出特點是命令看上去更加的人性化迫靖, 而且有語法高亮
Feelings:
- 相比于curl命令上的變化還挺多的
- 而且更加的直觀,用官方的話說就是intuitive
- 簡單的json使用非常的方便
Notes:
- 官方網(wǎng)站
- 命令行命令是http
- http method:
- httpie支持restful風(fēng)格的請求
- ?如果請求中沒有數(shù)據(jù)就自動發(fā)get請求兴使, 如果有就發(fā)post請求—這個沒實踐的時候發(fā)現(xiàn)不太對系宜,都發(fā)的get請求
- 如果是其他method,可以按如下方式使用发魄,很類似于http的請求格式:
http DELETE example.org/todos/7
- Request URL
- 對localhost有特別的shortcuts盹牧,可以省略前面的localhost這個字符串
http :8080/foo
## 以下是回復(fù)
GET /foo HTTP/1.1
Host: localhost
- 可以給https一個別名,方便使用
alias https='http --default-scheme=https'
-
Request Items:通過分隔符去區(qū)分各種類型的item励幼,而不是參數(shù)選項
- JSON, 使用很簡潔:
? ~ http POST :8080/jsonTest name="kk" age=123
# 以下是回復(fù)
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的用例需要自己搭建本地服務(wù)