linux发送http请求收集

如果http地址中包含英文叹号(!),应加反斜线转义(\!)

curl GET请求

curl GET请求不带参数

格式:

curl -X GET http地址

示例:

curl -X GET http://127.0.0.1:8080/update-comp

curl GET请求带params参数

格式:

curl -X GET http地址?key1=value1&key2=value2

示例:

curl -X GET http://127.0.0.1:8080/update-comp?t=ftws&sid=123

curl GET请求带x-www-form-urlencoded参数

格式:

curl -X GET -H 'Content-Type: application/x-www-form-urlencoded' -d 'key1=value1&key2=value2' http地址

示例:

curl -X GET -H 'Content-Type: application/x-www-form-urlencoded' -d 't=ftws&sid=123' http://127.0.0.1:8080/update-comp

curl GET请求带form-data参数

格式:

curl -X GET -H 'content-type: multipart/form-data;' -F 'key1=value1' -F 'key2=value2' http地址

示例:

curl -X GET -H 'content-type: multipart/form-data;' -F 't=ftws' -F 'sid=123' http://127.0.0.1:8080/update-comp

curl GET请求带header参数

格式:

curl -X GET -H 'key1: value1' -H 'key2: value2' http地址

示例:

curl -X GET -H 'cache-control: no-cache' -H 'sid: 234' http://127.0.0.1:8080/update-comp

curl POST请求

curl POST请求不带参数

格式:

curl -X POST http地址

示例:

curl -X POST http://127.0.0.1:8080/update-comp

curl POST请求带json参数

json数据要放在单引号里面
格式:

curl -X POST -H "Content-Type:application/json" -d 'json数据' http地址

示例:

curl -X POST -H "Content-Type:application/json" -d '{"fileNames":["20210626","20210627","20210628","20210629"]}' http://127.0.0.1:8080/delete-file

curl POST请求带x-www-form-urlencoded参数

json数据要放在单引号里面
格式:

curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d 'key1=value1&key2=value2' http地址

示例:

curl -X POST -H "Content-Type:application/x-www-form-urlencoded" -d 'token=123&id=3456' http://127.0.0.1:8080/update

curl POST请求带form-data参数

key3的值为文件路径
格式:

curl -X POST -H 'content-type: multipart/form-data;' -F 'key1=value1' -F 'key2=value2' -F='key3=@文件路径' http地址

示例:

curl -X POST-H 'content-type: multipart/form-data;' -F 't=ftws' -F 'sid=123' -F 'key3=@D:\ceshi\dlaqfgwlb2.pdf' http://127.0.0.1:8080/update-comp

curl POST请求带header参数

格式:

curl -X POST -H 'key1: value1' -H 'key2: value2' http地址

示例:

curl -X POST -H 'cache-control: no-cache' -H 'sid: 234' http://127.0.0.1:8080/update-comp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值