win7下IntelliJ IDEA使用curl

curl是利用URL語法在命令行方式下工做的開源文件傳輸工具html

curl命令能夠在開發web應用時,模擬前端發起的HTTP請求前端

1.下載curlweb

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

 

 

 我選擇的,Windows 64 bit 7.65.3 binary the curl project,curl-7.65.3_1-win64-mingw.zipapi

2.解壓app

  curl-7.65.3_1-win64-mingwcurl

3.設置環境變量工具

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

4.配置IntelliJ IDEA測試

file——>settings——>Terminalui

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:8080/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:8080/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:8080/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:8080/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="}

相關文章
相關標籤/搜索