GET请求
使用curl发送GET请求:curl protocol://address:port/url?args
如:
curl http://127.0.0.1:8080/login?admin&passwd=12345678
POST请求
使用curl发送POST请求:curl -d “args” protocol://address:port/url
curl -d "user=admin&passwd=12345678" http://127.0.0.1:8080/login
如果请求参数要设置在body中:
curl -H “Content-Type:application/json” -X POST -d ‘json data’ URL
curl -H "Content-Type:application/json" -X POST -d '{"user": "admin", "passwd":"12345678"}' http://127.0.0.1:8000/login
如果涉及到 域名无法解析的问题,如: can not reslove number.haoma 等,可以通过 --resolve来自己映射,
# --resolve参数形式
--resolve host:port:address
# 示例
curl --resolve moonagic.com:443:127.0.0.1 https://moonagic.com
完整实例:
curl -H "Content-Type:application/json" -X POST -d '{"loginName": "user", "password":"123456","userId":"boss"}' --resolve agentweb.sungoin.com:80:139.196.141.11 http://agentweb.sungoin.com/getCgiToken