curl 命令参数
-o #output保存到文件中 curl -o [文件名] www.sina.com
-i #显示 response的头信息 curl -i www.sina.com
-v #显示详细信息
-X #默认是 GET ,可以指定 POST PUT 等
-h / --header #添加头信息
-d/ --data
#发送数据
# 发送表单参数 -d '{"name":"lisi","age":14}'
# 请求头参数(类似 your_url?a=1&b=2) -d "a=1&b=2"
-u/--user
# http认证 curl --user name:password example.com
示例:
发送 json表单请求
curl -H "Content-Type: application/json" -d '{"name":"admin","password":"admin"}' http://request_url
发送 post请求
curl -X POST http://your_url
httpie 命令参数
安装 请移步github
语法格式:
http [flags] [METHOD] URL [ITEM [ITEM]]
请求项
Item Type | Description |
---|---|
HTTP HeadersName:Value | Arbitrary HTTP header, e.g. X-API-Token:123 . |
URL parametersname==value | Appends the given name/value pair as a query string parameter to the URL. The == separator is used. |
Data Fieldsfield=value ,field=@file.txt | Request data fields to be serialized as a JSON object (default), or to be form-encoded (--form, -f ). |
Raw JSON fieldsfield:=json ,field:=@file.json | Useful when sending JSON and one or more fields need to be a Boolean , Number , nested Object , or an Array , e.g., meals:='["ham","spam"]' or pies:=[1,2,3] (note the quotes). |
Form File Fieldsfield@/dir/file | Only available with --form, -f . For example screenshot@~/Pictures/img.png . The presence of a file field results in a multipart/form-data request. |
示例
json data
http PUT example.org name=John
form data
http -f POST example.org hello=World
query params
http www.google.com search=='HTTPie logo' tbm==isch
Digest auth
http -A digest -a username:password example.org