In this article we will split the essentials you have to know about the new communications protocol HTTP/2. Furthermore, we will discover some interesting resources which will allow you to adapt to this new way of client-server information exchange in an easier way.
- What is HTTP/2?
- Key features
- How an HTTP/2 connection is established in our browser?
- Which browsers support HTTP/2?
- HTTP/2 with Java
The growing amount of Internet users and the intention of improving both time and performance of the client-server information exchange protocols have ended in the creation of, almost 20 years after since HTTP 1.1 version was released, the new version of the application protocol: the famous HTTP/2
2. What is HTTP/2?
HTTP/2 is the new binary application protocol (OSI model), which has same semantics of the previous version, HTTP/1.1. That means both verbs and headers will work without appliying any change.
3. Key features
The key features we should attend are:
- Binary protocol: Unlike the previous one, which was based on text, HTTP/2 uses direclty the machine language (binary) to exchange information. This makes it easier to interprete, less error-prone, and faster.
- Multiplexing: HTTP/2 uses unique identifiers kept within the binary frames which are sent/received to multiplex the iinformation and be able to manage different type content with less resources.
- Unique connection: HTTP/2 is able to handle client-server information exchange using only one connection. This makes it was specially useful to save resources, and accelerate the information exchange.
- Headers compression: HTTP/2 brings in headers compression out-of-the-box, which allows to minimize the information exchange and reduce the latency.
- ‘Server-push’ service: HTTP/2 is able to push required resources to the browser cache using its binary connection, even before this had been able to interprete the served page HTML.
4. How an HTTP/2 connection is established in our browser?
We have to keep in mind that, regardless the encryption is not mandatory in a client-server connection based on the official HTTP/2 RFC, none browser will allow us to use HTTP/2 without encryption.
Due to this fact, in this article it will be explained the normal way of how an HTTP/2 connection is made: Using the ALPN extension (Application Layer Protocol Negotiation) of TLS (Transport Layer Security), which is the recommended standard of connection encryption supported by the most browsers practically.
Attending this, we should have a browser which supports HTTP/2. If we access to a certain site using HTTPS, the browser will make a TLS1.2 “ClientHello” request, where it will be specified if the browser supports HTTP/2 (h2 protocol) using the ALPN extension.
Step 1 of 2: TLS1.2 ClientHello
Following this step, the server will response with the TLS 1.2 “ServerHello” message using the same ALPN extension. This response will confirmed to the client that server will use HTTP/2 to established communications (h2 protocol).
Step 2 of 2: TLS1.2 ServerHello
From here on, the HTTP/2 connection will have been established and the server will start sending binary data frames to the browser.
5. Which browsers support HTTP/2?
We could know which browsers supports HTTP/2 using the following link: HTTP/2 supported browsers
We may also check the same information using the following image extracted directly from the previous link.
For those of you programmers who are working / experimenting with this new protocol, here you could find a couple of plugins to know if you are actually using HTTP2 protocol.
7. HTTP/2 with Java
You have to know that, since HTTP/2 is a quite recent protocol (2015), Java does not have native support for ALPN until JDK v9.
That means if we want to use ALPN connections with JDK 1.8 or previous, it is possible we should use external libraries to startup our application depending on the servlets container or application server we were using.
In the following link, we could take a quick look at those Java based server implementations which support HTTP/2 protocol. HTTP/2 supported server implementations
In this article we have seen the essentials we should know about HTTP/2 being a good starting point to start our development tasks with this new protocol and the new servlets containers / application servers which support it.