curl
Common Options
-
- #, --progress bar
:使用简单的progress bar,而不是更多信息的标准仪表 -
-b, --cookie <data=name>
:使用cookie -
-c, --cookie-jar <file name>
:使用cookie文件 -
-d, --data <data>
:提供data数据 -
-f, --fail
:返回失败静默处理 -
-F, --form
:提供form数据 -
-H, --header <header>
:设置header -
-i, --include
:显示header -
-I, --head
:仅提取header -
-k, --insecure
:允许不安全的连接 -
-L, --location
:允许重定向 -
-o, --output
:指定输出文件,可以通过--create-dirs
创建目录 -
-O, --remote-name
:输出远程文件 -
-s, --silent
:静默模式,使用-S
强制显示错误 -
-v, --verbose
:提供更多信息,比如debug信息 -
-w, --write-out
:添加额外的输出信息 -
-X, --request
:请求方法
POST
发送POST和PUT请求常用的两张数据格式标准头
-
application/json
-
application/x-www-form-urlencoded
数据格式对应:
-
-d '{"key1":"value1", "key2":"value2"}'
or-d @data.json
-
-d "param1=value1¶m2=value2"
or-d @data.txt
Examples
-
POST application/x-www-form-urlencoded
curl -d "param1=value1¶m2=value2" -X POST http://localhost:3000/data
curl -d "@data.txt" -X POST http://localhost:3000/data
-
POST application/json
curl -d '{"key1":"value1", "key2":"value2"}' \ -H "Content-Type: application/json" \ -X POST http://localhost:3000/data
curl -d "@data.json" -X POST http://localhost:3000/data
参考链接
- curl, subfuzion