• 请不要在回答技术问题时复制粘贴 AI 生成的内容
jdz
V2EX  ›  程序员

看了下百度 https 网址既提供 http2 也提供 http1.1, 怎样指定 http2 呢. 使用 curl 怎么指定参数都无效 浏览器也是 http1.1

  •  
  •   jdz · Jan 11, 2022 · 2667 views
    This topic created in 1604 days ago, the information mentioned may be changed or developed.
    9 replies    2022-01-11 11:35:45 +08:00
    ysc3839
        1
    ysc3839  
       Jan 11, 2022
    那就说明不支持吧
    aladdinding
        2
    aladdinding  
       Jan 11, 2022   ❤️ 1
    ssl 握手中有个啥扩展 可以协商接下来使用啥协议 如果支持 h2 服务端就会返回支持 h2
    unco020511
        3
    unco020511  
       Jan 11, 2022
    Connection: Upgrade, HTTP2-Settings
    Upgrade: h2c
    检索关键词: http 协议升级协商机制
    yaoyaomoe
        4
    yaoyaomoe  
       Jan 11, 2022   ❤️ 1
    多个网站测都是:www.baidu.com
    HTTP/2 protocol is not supported.

    ssllabs 测试:
    ALPN Yes http/1.1
    NPN Yes http/1.1

    本地测试:
    ```bash
    > is-http2 www.baidu.com
    × HTTP/2 not supported by www.baidu.com
    > curl -sI --http2 百度 |grep HTTP
    HTTP/1.1 200 OK
    ```
    所以暂时应该是不支持……猜测是向下兼容 IE 所以不能直接升级,SSL3 和 TLS1.0 可能有 bug ?
    darknoll
        5
    darknoll  
       Jan 11, 2022
    你说的 http2 是 cdn 来的吧
    jdz
        6
    jdz  
    OP
       Jan 11, 2022 via Android
    @yaoyao1128 我用的 curl -v 查看的,offerring http2 ,然后跟着 offering hpttp1.1 ,你可以试试
    2i2Re2PLMaDnghL
        7
    2i2Re2PLMaDnghL  
       Jan 11, 2022
    ALPN 信息不代表真实提供的选项
    2i2Re2PLMaDnghL
        8
    2i2Re2PLMaDnghL  
       Jan 11, 2022   ❤️ 2
    我再看了一遍
    offering 似乎说的是你在 ClientHello 的时候 offer 了 h2 和 http/1.1
    之后 ALPN, server accepted to use http/1.1

    可以看一下 rfc7301
    ClientHello 的时候提供 list of protocols ,ServerHello 的时候提供 selected protocol 并开始密钥交换
    yaoyaomoe
        9
    yaoyaomoe  
       Jan 11, 2022 via iPhone   ❤️ 3
    @jdz ALPN 的过程是这样的
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * ALPN, server accepted to use http/1.1
    这里是 Client 给 server 发一个列表 说我支持什么 之后 server 从里面选择一个进行返回 说我支持这个我们用这个交换 然后 server 给 client 说我的证书是怎么怎么的
    所以说 alpn 的前两个是客户端能提供(或者说 能处理)的协议 相比较 npn 多了一个 hello 的过程确定协议
    alpn 是 rfc7301 的内容
    datatracker.ietf.org/doc/html/rfc7301
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5838 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 62ms · UTC 03:39 · PVG 11:39 · LAX 20:39 · JFK 23:39
    ♥ Do have faith in what you're doing.