Windows下安装使用curl命令

本机环境

Windows 7

 

方法/步骤

1、进入网站

https://curl.haxx.se/download/?C=M;O=D网站

2、根据自己的操作系统位数和是否需要SSL下载相应的版本。

这里下载curl-7.33.0-win64-ssl-sspi.zip,下载完成之后解压到需要使用curl命令的目录。这里为了方便我先直接解压到当前目录。

wKioL1cPdn_yMnUvAAF57hPQxaI487.png


wKiom1cPdcfQ_8saAABgDegr2b4246.png

3、在本窗口下打开运行该命令

【没有建立系统环境变量,所以只能在本目录下运行】,检测是否可以正常运行

wKiom1cPdciw-phZAABVMl-NKpg216.png

注意:

         想得到上面的“在此处打开命令窗口(W)”,请使用键盘 Shift+鼠标右键 即可

 

wKioL1cPdoCQ2ihTAABuUXyq8UM685.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
C:\common_command>curl - v  -X OPTIONS https: //www .baidu.com/ 
*Adding handle: conn: 0x205e100
*Adding handle: send: 0
*Adding handle: recv: 0
*Curl_addHandleToPipeline: length: 1
* -Conn 0 (0x205e100) send_pipe: 1, recv_pipe: 0
*About to connect() to www.baidu.com port 443 ( #0)
*   Trying 220.181.112.244...
* Connectedto www.baidu.com (220.181.112.244) port 443 ( #0)
*SSLv3, TLS handshake, Client hello (1):
*SSLv3, TLS handshake, Server hello (2):
*SSLv3, TLS handshake, CERT (11):
*SSLv3, TLS alert, Server hello (2):
* SSLcertificate problem: unable to get  local  issuer certificate
*Closing connection 0
curl:(60) SSL certificate problem: unable to get  local  issuer certificate
Moredetails here: http: //curl .haxx.se /docs/sslcerts .html
  
curlperforms SSL certificate verification by default, using a  "bundle"
  of Certificate Authority (CA) public keys (CAcerts). If the default
  bundle  file  isn't adequate, you can specify analternate  file
  using the --cacert option.
Ifthis HTTPS server uses a certificate signed by a CA represented  in
  the bundle, the certificate verificationprobably failed due to a
  problem with the certificate (it might beexpired, or the name might
  not match the domain name  in  the URL).
Ifyou 'd like to turn off curl' s verification of the certificate, use
  the -k (or --insecure) option.
  
C:\common_command>

4、加入系统环境变量

wKioL1cPdoCB4vh-AAEariMrFRM014.png

wKiom1cPdcmSfyERAABmN29lbWg804.png

用户变量和系统变量的区别:

         答: 用户变量:指在该用户登录后该环境变量有效。

              系统变量:指任何用户登录该系统,该环境变量都有效。

           怎么使用:判断该环境变量是否敏感或者是否有用户限制,如果没有则配置在系统变量;否则请根据敏感度或者限制情况配置在用户的环境变量,有利于安全。

 

wKioL1cPdoGjFZ8cAACJox4vms0305.png

wKiom1cPdcmRv6dzAACIg0oacUc551.png

5、在其他路径下测试是否可以使用CURL命令

wKioL1cPdoHB9jMFAADhAjWo5mU688.png

成功!

 

 

6、该命令常用作用

答:

1、用于查看该网站可以允许有哪些http请求  【常用:GET, HEAD, POST,PUT, DELETE, OPTIONS

         我们经常不希望有PUTDELETE请求,如果有则需要关闭;因为容易造成一些安全问题。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[zhang@zhang ~]$ curl - v  -X OPTIONS https: //www .aliyun.com/
*About to connect() to www.aliyun.com port 443 ( #0)
*   Trying 42.156.220.114... connected
*Connected to www.aliyun.com (42.156.220.114) port 443 ( #0)
*Initializing NSS with certpath: sql: /etc/pki/nssdb
*   CAfile:  /etc/pki/tls/certs/ca-bundle .crt
   CApath: none
* SSLconnection using TLS_RSA_WITH_AES_128_CBC_SHA
*Server certificate:
*       subject: CN=*.aliyun.com,O= "Alibaba(China) Technology Co., Ltd." ,L=HangZhou,ST=ZheJiang,C=CN
*       start  date : 12月 14 10:47:07 2015 GMT
*       expire  date : 12月 14 10:39:17 2016 GMT
*       common name: *.aliyun.com
*       issuer: CN=GlobalSign OrganizationValidation CA - G2,O=GlobalSign nv-sa,C=BE
>OPTIONS / HTTP /1 .1
>User-Agent: curl /7 .19.7 (x86_64-redhat-linux-gnu) libcurl /7 .19.7 NSS /3 .19.1Basic ECC zlib /1 .2.3 libidn /1 .18 libssh2 /1 .4.2
>Host: www.aliyun.com
>Accept: */*
<HTTP /1 .1 200 OK
<Date: Thu, 14 Apr 2016 05:16:27 GMT
<Content-Type: text /html ; charset=utf-8
<Transfer-Encoding: chunked
<Connection: close
<Vary: Accept-Encoding
<Server: Tengine
<Vary: Accept-Encoding
<Vary: Accept-Encoding
< Allow: GET
<Strict-Transport-Security: max-age=31536000
<Timing-Allow-Origin: *
  
*Closing connection  #0


另请参考:Windows下安装使用curl命令



  • 7
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值