计算机网络 - 如何查看一个网站是否使用HTTP/2?

方法

  1. HTTP/2用":authority"头部代替"Host"头部。
  2. Chrome F12里面,HTTP/1.1有"view source",而HTTP/2是binary,没有"view source"。
  3. Chrome F12 Network里面设置"Protocol"。
  4. 有些网站可以提供此类服务。例如 https://tools.keycdn.com/http2-test

TL;DR 提出这个问题的过程

在看一篇关于nginx的文章。http://nginx.org/en/docs/http/request_processing.html。 里面有一段话:In this configuration nginx tests only the request’s header field “Host” to determine which server the request should be routed to.
然后随便选一个网站,寻找"Host"头,发现有些网站没有。查一下MDN,说一定要有这个头。

A Host header field must be sent in all HTTP/1.1 request messages. A 400 (Bad Request) status code will be sent to any HTTP/1.1 request message that lacks a Host header field or contains more than one.

认真一看,原来是HTTP/1.1。
发现":authority"和"Host"头类似,则google。找到 https://stackoverflow.com/questions/36019868/authority-http-header-in-chrome-dev-tools

另外,还发现Chorme F12有些请求不能"view source",google一下。https://stackoverflow.com/questions/40800140/how-does-view-source-in-response-headers-go-missing-for-certain-sites
原来HTTP/2是二进制的,无法view source。看了一些网站,发现HTTP/2普及率挺高的。引起了学习研究HTTP/2的兴趣。

猜你喜欢

转载自www.cnblogs.com/allen2333/p/12016580.html