Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

http2 - How does a browser know if a site supports HTTP/2?

If I type out https://http2.golang.org/ the chrome browser will automatically send the HTTP/2 request. How is this done?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Take stackoverflow for example, when the browser sends a request to stackoverflow.com, it has to do the following steps:

  1. DNS lookup. find the ip address of stackoverflow.
  2. TCP/IP handshake
  3. TLS handshake.
  4. HTTP request/response (Application Protocol).
  5. ....

TLS handshake

Regarding step3 TLS handshake, there is an nice explanation by @Oleg.

In order to inspect the detail of TCP/IP packet, You may need use some tools to capture packets. e.g. Wireshark.

Client sends ClientHello to server, which carries several things

  • supported cipher suite. which cipher suites do you like?
  • supported TLS version.
  • a random number.
  • the supported Application Protocols. e.g. HTTP/2, HTTP 1.1/ Spdy/..
  • ...

Client Hello

Server responds SeverHello, which carries

enter image description here

Conclusion

HTTP2 request/response happens in step4. Before that, browser has already know whether sever support HTTP/2 through TLS handshake.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...