方法
- HTTP/2用":authority"頭部代替"Host"頭部。
- Chrome F12里面,HTTP/1.1有"view source",而HTTP/2是binary,沒有"view source"。
- Chrome F12 Network里面設置"Protocol"。
- 有些網站可以提供此類服務。例如 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的興趣。