是否有命令或服务告诉我我的网站是通过HTTP还是HTTP / 2提供服务。
我找到了这个工具:HTTP/2 Test | A simple HTTP/2.0 test tool,但它只告诉我我的网站是否支持HTTP / 2,而不是它是否已经使用HTTP / 2。
这些也是Chrome扩展程序:HTTP/2 and SPDY indicator,它告诉我HTTP / 2已在我的网站上启用,但据我所知,我的Apache版本甚至不支持它。
有没有办法确定?谢谢!
Apache不必支持它。 Chrome扩展程序会读取HTTP标头以确定该标头。
另一种方法是查看Chrome或Firefox中的网络选项卡>标题>响应标题>查看源。在那里可以看到标题。它应该是“HTTP / 2”或者我现在不记得的那种。
最简单:您可以使用curl -I <your site>
将HTTP响应作为第一行。
HTTP/2.0 200
server:nginx
date:Fri, 29 Apr 2016 14:31:40 GMT
content-type:text/html; charset=utf-8
content-length:7629
last-modified:Thu, 07 Apr 2016 02:41:08 GMT
....
您也可以尝试--http2
或--http2-prior-knowledge
。这些将强制webiste使用HTTP / 2.0:
从卷曲手册:
--http2-prior-knowledge
(HTTP) Tells curl to issue its non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade. It requires
prior knowledge that the server supports HTTP/2 straight away. HTTPS requests will still do HTTP/2 the
standard way with negotiated protocol version in the TLS handshake.
--http2-prior-knowledge requires that the underlying libcurl was built to support HTTP/2. This option
overrides --http1.1 and -0, --http1.0 and --http2. Added in 7.49.0.
--http2
(HTTP) Tells curl to use HTTP version 2.
See also --no-alpn. --http2 requires that the underlying libcurl was built to support HTTP/2. This option
overrides --http1.1 and -0, --http1.0 and --http2-prior-knowledge. Added in 7.33.0.
对于使用Nginx的人,您可以查看通常位于/var/log/nginx/access.log
的访问日志,并查找类似的行
167.220.232.9 - - [12/Feb/2018:15:09:04 +0800] "GET / HTTP/2.0" 200 2546 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"