美文网首页
【Curl测试http2.0】

【Curl测试http2.0】

作者: 景贤游子_小跟班 | 来源:发表于2020-05-28 08:05 被阅读0次

    由于 CentOS 7 内置的 curl 和 libcurl 源为较旧的 7.29.0,不支持一些新特性且有安全性问题,所以需要更新一下。

    在这里使用 city-fan 的更新源来更新。

    一、 更新 ca-bundle
    首先备份一下:

    cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak
    

    更新并替换:

    curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt
    

    二、 新增 repo 源
    新增 repo:

    vim /etc/yum.repos.d/city-fan-for-curl.repo
    

    内容为:

    [CityFanforCurl]
    name=City Fan Repo
    baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/
    enabled=0
    gpgcheck=0
    

    更新 curl
    直接使用如下命令进行更新:

    yum update curl --enablerepo=CityFanforCurl -y
    

    测试http2.0

    curl --http2 -vo /dev/null  "https://www.example.com"  --resolve "www.example.com:443:IP"
    
    > GET / HTTP/2
    > Host: www.example.com
    > user-agent: curl/7.70.0
    > accept: */*
    > 
    * Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
    < HTTP/2 200 
    < server: nginx
    < date: Thu, 28 May 2020 00:02:42 GMT
    < content-type: text/html
    < content-length: 430032
    < accept-ranges: bytes
    < etag: "28c465b661fc10bd3048b0d83bafd969"
    < last-modified: Wed, 27 May 2020 23:51:39 GMT
    < set-cookie: secure=true;HttpOnly=true
    < x-frame-options: SAMEORIGIN
    < x-amz-id-2: PSnM9Fz7rdZq0QXWKTuXIpFVqM1YEADbtVzmXZqSrys6TIzn0QhDw/4xT59GAZypXsLQ4sM7Tp4=
    < x-amz-request-id: 12112A493B7B0AEC
    < x-amz-version-id: lS08YmEi2sk1lSd7J4LoVv0Hms70R_fu
    

    相关文章

      网友评论

          本文标题:【Curl测试http2.0】

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