curl

curl 常用命令

记录一下常用的 curl 命令,工作上自测用的比较多的

Hannah
2021-06-16
2 min

# 简介

curl(client URL)是常用的命令行工具

# 常用命令

# 1. GET 请求获取数据

curl https://127.0.0.1:3000/user/list

curl https://127.0.0.1:3000/user/list?status=normal

# 2. POST 请求发送数据 -d

curl -d'username=xxx&password=xxx' https://127.0.0.1:3000/login

curl -d 'username=xxx' -d 'password=xxx' https://127.0.0.1:3000/login

# 3. 添加 HTTP 请求的标头 -H

curl -H 'Authorization: xxx' https://127.0.0.1:3000/user/list

curl -H 'Authorization: xxx' -H 'Accept-Language: en-US' https://127.0.0.1:3000/user/list

# 4. 跳过 SSL 检测

curl -k https://127.0.0.1:3000/user/list

# 5. 指定 HTTP 请求的方法 -X

curl -X POST -d'username=xxx&password=xxx' https://127.0.0.1:3000/login

参考:curl 的用法指南

Last Updated: 2/25/2022, 10:24:15 AM
  • 2. POST 请求发送数据 -d