curl是利用URL语法在命令行方式下工作的开源文件传输工具

curl命令可以在开发web应用时,模拟前端发起的HTTP请求

1.下载curl

https://curl.haxx.se/download.html

我选择的,Windows 64 bit 7.65.3 binary the curl project,curl-7.65.3_1-win64-mingw.zip

2.解压

  curl-7.65.3_1-win64-mingw

3.设置环境变量

set PATH=E:\software\curl-7.65.3_1-win64-mingw\bin;%PATH%

4.配置IntelliJ IDEA

file——>settings——>Terminal

5.使用,打开

测试:

E:\software\curl-7.65.3_1-win64-mingw\bin>curl baidu.com

<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>

-i 详细信息

E:\software\curl-7.65.3_1-win64-mingw\bin>curl -i baidu.com

HTTP/1.1 200 OK
Date: Mon, 02 Sep 2019 06:11:13 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Tue, 03 Sep 2019 06:11:13 GMT
Connection: Keep-Alive
Content-Type: text/html

<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>

E:\software\curl-7.65.3_1-win64-mingw\bin>curl localhost:/find

[{"id":1,"name":"111"},{"id":2,"name":"222"},{"id":33,"name":"abc"},{"id":34,"name":"xyz"},{"id":65,"name":"abc"},{"id":66,"name":"xyz"}]

E:\software\curl-7.65.3_1-win64-mingw\bin>curl -i localhost:/find

HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 02 Sep 2019 06:13:16 GMT

[{"id":1,"name":"111"},{"id":2,"name":"222"},{"id":33,"name":"abc"},{"id":34,"name":"xyz"},{"id":65,"name":"abc"},{"id":66,"name":"xyz"}]

模拟formdata数据

E:\software\curl-7.65.3_1-win64-mingw\bin>curl  localhost:/api/getPost -X POST  --data "id=1&name=abc"

{"id":1,"name":"abc","other":null,"string":" id=1 name=abc other=null"}

json数据

E:\software\curl-7.65.3_1-win64-mingw\bin>curl localhost:/api/getPostJson  -X POST  -H "Content-Type:application/json"   --data "{\"id\":\"1\",\"name\":\"abc\",\"other\":\"\"}"

{"id":1,"name":"abc","other":"","string":" id=1 name=abc other="}

最新文章

  1. JavaScript中Promises/A+规范的实现
  2. Python列表切成多个
  3. IOS设计模式的六大设计原则之开放-关闭原则(OCP,Open-Close Principle)
  4. Tomcat报java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
  5. Sublime Text 3 破解版 + 注册机 + 汉化包 + 教程
  6. 毫秒数转换为指定格式日期的js代码
  7. SQL Server访问MySql
  8. css @语法,@规则 @import @charset @font-face @fontdef @media @page
  9. iOS 之点击按钮改变状态的图片
  10. hdu 5625 Clarke and chemistry
  11. linux下维护服务器之常用命令
  12. HTML5_表单元素
  13. 金三银四跳槽季,BAT美团滴滴java面试大纲(带答案版)之一:Java基础篇
  14. Essential Phone PH1原生系统常见问题以及解答
  15. Dining POJ - 3281
  16. msp430板子接485接口的气体传感器问题及处理
  17. 3种web会话管理方式
  18. 使用任务Task 简化异步编程
  19. MVC中使用EF的技巧集(二)——分部验证
  20. Crawling is going on - Beta版本测试报告

热门文章

  1. 什么是JavaEE,什么是Spring
  2. 第9章 MyBatis的关系映射
  3. 总结TestNg与JUnit的异同
  4. 【C/C++】变量
  5. SOS从内存转储中提取模块(EXE、DLL和其他二进制文件)
  6. 5-(微信小程序篇)关于WiFi模块配网以后利用小程序绑定设备,绑定方式说明
  7. Linux执行shell脚本的方法
  8. 【BIEE】使用BIPublisher做报表时,选择多个参数使用IN的问题
  9. OpenFOAM——前台阶
  10. 在 Ubuntu/Debian 下安装 PHP7.3 教程