The first part of any usage of HTTP/2 is connection establishment. It would not be practical to allocate a new port just for HTTP/2 for various reasons, so instead the protocol defines 3 different methods of connection that allow the existing HTTP and HTTPS ports to be re-used.
-
ALPN based connection for https:// URIs
-
HTTP upgrade based connection http:// URIs
-
Connection via prior knowledge for hosts which are known to support HTTP/2
A detailed explanation of the three is given below. Once the initial connection has been established both the client and server send a connection preface, after which the connection is established.
HTTP/2 Connection methods
-
ALPN based connection for https:// URIs
-
ALPN
stands for
Application Layer Protocol Negotiation
, and is a TLS extension that allows a client to negotiate the next protocol to use after the TLS handshake is complete. If either the client or the server does not support ALPN, then it will be ignored, and HTTP/1.1 will be used instead.
When the client connects to the server it sends a list of supported protocols. The server will then decide on the next
protocol to use and send this back in its response. If the server decides to use HTTP/2 it will send pack 'h2' as the