Automatic HTTP/1.1 fallback
ALPN
This note describes how the server and browser agree on whether to use HTTP/2 or HTTP/1.1.
When a browser attempts to connect to the server, it initiates the TLS handshake protocol. This is where the client and server exchange secret keys in order to encrypt requests and responses. An important part of the handshake is for the client and server to agree on which version of HTTP to use. This agreement is reached using the TLS extension called Application Layer Protocol Negotiation (ALPN).
User agents (browsers & crawlers & postman tools) advertise whether they are ready to communicate with HTTP/1.1, or HTTP/2, or both. The Read Write Serve HTTP/2 server is able to communicate using either one, with the preference being HTTP/2.
If the user agent advertises that it is OK with HTTP/2, then the server will acknowledge that, and inform the user agent that sessions and streams will use HTTP/2. If the user agent only advertises HTTP/1.1, the server will acknowledge that and the socket will use HTTP/1.1.
If the user agent attempts to connect using HTTP/1.0 or HTTP/0.9, the server will respond with status code 505 Version not Supported.
Webmasters can monitor which protocol was choosen by logging the alpn
request header.
Plugin developers can determine which protocol is in force for any request/response, by calling the workOrder function getALPN()
, which will have the value http/2
or http/1.1
.