哪个网站在没有 SSL 的情况下支持 http/2 端口 80?

What website supports http/2 on port 80 with no SSL?

我想 运行 http/2 上的 wireshark 端口 80 到

1. be able to test out an http/2 client
2. follow a wireshark trace to understand the protocol better

有没有支持http/280端口的网站?当我转到 google 时,它总是将我更改为 https。

谢谢, 院长

Jetty 项目实现了一个 HTTP/2 服务器,可以使用加密 HTTP/2 和明文 HTTP/2。

您可以在本地轻松设置 Jetty h2c 服务器,支持直接 HTTP/2 通信以及支持 HTTP/1.1 升级到 HTTP/2.

我建议您不要用实验轰炸 public 服务器 :)

这是服务器代码:

public class H2C
{
    public static void main(String[] args) throws Exception
    {
        Server server = new Server();

        HttpConfiguration config = new HttpConfiguration();
        HttpConnectionFactory h1 = new HttpConnectionFactory(config);
        HTTP2CServerConnectionFactory h2 = new HTTP2CServerConnectionFactory(config);
        ServerConnector connector = new ServerConnector(server, h1, h2);
        connector.setPort(8080);
        server.addConnector(connector);

        server.setHandler(new AbstractHandler()
        {
            @Override
            protected void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
            {
                baseRequest.setHandled(true);
                // Your code here.
            }
        });

        server.start();
    }
}

您可以使用 HTTP/2 客户端来测试服务器,例如 nghttp,并通过 Wireshark 观察流量。

通过升级测试明文 HTTP/2(使用 -u 标志,-v 标志用于冗长):

$ nghttp -uv http://localhost:8080/

[  0.000] Connected
[  0.000] HTTP Upgrade request
GET / HTTP/1.1
host: localhost:8080
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.7.1


[  0.001] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols


[  0.001] HTTP Upgrade success
[  0.001] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
      (dep_stream_id=0, weight=201, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
      (dep_stream_id=0, weight=101, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
      (dep_stream_id=0, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
      (dep_stream_id=7, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
      (dep_stream_id=3, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
      (dep_stream_id=11, weight=16, exclusive=0)
[  0.001] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.002] recv (stream_id=1) :status: 200
[  0.002] recv (stream_id=1) server: Jetty(9.4.z-SNAPSHOT)
[  0.002] recv (stream_id=1) date: Fri, 20 May 2016 09:38:52 GMT
[  0.002] recv HEADERS frame <length=45, flags=0x05, stream_id=1>
      ; END_STREAM | END_HEADERS
      (padlen=0)
      ; First response header
[  0.002] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
      (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])

或直接测试明文HTTP/2:

$ nghttp -v http://localhost:8080/

[  0.000] Connected
[  0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
      (dep_stream_id=0, weight=201, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
      (dep_stream_id=0, weight=101, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
      (dep_stream_id=0, weight=1, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
      (dep_stream_id=7, weight=1, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
      (dep_stream_id=3, weight=1, exclusive=0)
[  0.000] send HEADERS frame <length=38, flags=0x25, stream_id=13>
      ; END_STREAM | END_HEADERS | PRIORITY
      (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
      ; Open new stream
      :method: GET
      :path: /
      :scheme: http
      :authority: localhost:8080
      accept: */*
      accept-encoding: gzip, deflate
      user-agent: nghttp2/1.7.1
[  0.095] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.095] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.096] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.105] recv (stream_id=13) :status: 200
[  0.105] recv (stream_id=13) server: Jetty(9.4.z-SNAPSHOT)
[  0.105] recv (stream_id=13) date: Fri, 20 May 2016 09:39:30 GMT
[  0.105] recv HEADERS frame <length=45, flags=0x05, stream_id=13>
      ; END_STREAM | END_HEADERS
      (padlen=0)
      ; First response header
[  0.106] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
      (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])