美文网首页
curl模拟HTTP GET和POST请求

curl模拟HTTP GET和POST请求

作者: 徐德东 | 来源:发表于2018-03-06 16:36 被阅读0次

curl是一个很棒的命令.

1:get请求

curl http://localhost:9090/api/v1/get/data/?id=10

2:post请求

1): curl  -d  '{"id":"10",  "imagename":"imagename"}' http://localhost:9090/api/v1/update/imagename/

这种方法是参数直接在header里面的,如需将输出指定到文件可以通过重定向进行操作

2): curl -H "Content-Type:application/json" -X POST -d '{"id":"10", "test_flag":2, "pre_imagename":"imagename"}' http://localhost:9090/api/v1/update/pre_imagename/

这种方法是json数据直接在body里面的。

其中-d可以用--data参数来替换

相关文章

网友评论

      本文标题:curl模拟HTTP GET和POST请求

      本文链接:https://www.haomeiwen.com/subject/lrlrfftx.html