HTTP / 2服务器推送现在不与Zeit一起使用

问题描述 投票:0回答:1

在我的项目中,由于Zeit支持HTTP / 2,我正在尝试进行HTTP / 2服务器推送。

因此,我在请求中添加了必要的链接头。

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLmltZ3VyLmNvbS94Z0dYZjEzLmpwZyJ9” alt =“ HTTP / 2推送标头”>

但是当我检查网络选项卡时,initiator显示为Other而不是Push/Other

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLmltZ3VyLmNvbS9PaXg4bWRZLmpwZyJ9” alt =“未显示”>

然后,我检查了另一个站点:https://http2-server-push-demo.keksi.io/,在这里清楚地显示了Push。

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLmltZ3VyLmNvbS9sY3RMNHliLmpwZyJ9” alt =“推送工作标头”>

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLmltZ3VyLmNvbS9aanZsbHczLmpwZyJ9” alt =“推送工作屏幕截图”>

这里发生了什么?我不理解。我正在使用Now CLI v16.4.4。谁能帮忙?

一些调试信息

如果需要,这里是一些命令输出:

命令: curl --http2 -v https://example.com

curl --http2 -v https://ccrewards.in
 * Rebuilt URL to: https://ccrewards.in/
 *   Trying 13.234.90.190...
 * TCP_NODELAY set
 * Connected to ccrewards.in (13.234.90.190) port 443 (#0)
 * ALPN, offering h2
 * ALPN, offering http/1.1
 * successfully set certificate verify locations:
 *   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
 * TLSv1.2 (OUT), TLS handshake, Client hello (1):
 * TLSv1.2 (IN), TLS handshake, Server hello (2):
 * TLSv1.2 (IN), TLS handshake, Certificate (11):
 * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
 * TLSv1.2 (IN), TLS handshake, Server finished (14):
 * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
 * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
 * TLSv1.2 (OUT), TLS handshake, Finished (20):
 * TLSv1.2 (IN), TLS handshake, Finished (20):
 * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
 * ALPN, server accepted to use h2
 * Server certificate:
 *  subject: CN=ccrewards.in
 *  start date: Oct 25 06:44:21 2019 GMT
 *  expire date: Jan 23 06:44:21 2020 GMT
 *  subjectAltName: host "ccrewards.in" matched cert's "ccrewards.in"
 *  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
 *  SSL certificate verify ok.
 * Using HTTP2, server supports multi-use
 * Connection state changed (HTTP/2 confirmed)
 * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
 * Using Stream ID: 1 (easy handle 0x7fffe6a71b70)
> GET / HTTP/2
> Host: ccrewards.in
> User-Agent: curl/7.58.0
> Accept: */*
>
 * Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200
< content-type: text/html; charset=utf-8
< link: </css/bootstrap.min.css>; rel=preload; as=style, </css/placeholder-loading.min.css>; rel=preload; as=style
< date: Mon, 28 Oct 2019 18:06:54 GMT
< vary: User-Agent, Accept-Encoding
< content-encoding: gzip
< content-length: 28149
< etag: "4eadf-E5nKTWVXCBjTRiqdEed4eCgcd6A"
< accept-ranges: none
< cache-control: public, max-age=0, must-revalidate
< x-now-cache: STALE
< x-now-trace: bom1
< server: now
< x-now-id: bom1:bom1:48cbv-1572288058858-8bf8eca0e432
< strict-transport-security: max-age=63072000
<
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
 * Failed writing body (0 != 15963)
 * Connection #0 to host ccrewards.in left intact
nuxt.js http2 server-push zeit-now
1个回答
0
投票

仅仅因为服务器支持HTTP / 2并不意味着它支持HTTP / 2的所有功能。即使这样做,也并不意味着它会使用链接头来启动推送-这不是HTTP/2 spec中定义的,而是许多(但不是全部)服务器用来启动HTTP / 2推送的方法。

[使用nghttp检出您的站点(对于HTTP / 2调试而言,胜于curl),我看不到正在推送的帧以及来自服务器的帧。

我不喜欢Zeit-now,但谷歌很快建议它可能构建在不支持链接头作为Push方法的Node之上,而必须使用http2stream.pushStreamexplicitly initiate an HTTP/2 push

© www.soinside.com 2019 - 2024. All rights reserved.