This chapter demonstrates about the HTTP2 Client Side Libraries which demonstrates about the HTTP/2 applications and working with the libraries. Following are the concepts covered in this chapter.
Hosting HTTP/2 applications
Client side Libraries
Hosting HTTP/2 applications
Description
When it comes to server there are two aspects simply hosting a web site running on HTTP/2 with started pages etc and another aspect is hosting ASP.Net application and Java application, Server pages.
Hosting .Net Applications
In terms of Hosting .Net applications which is support on IIS 10 on windows 10 so usert can an essence use HTTP/2 transport on IIS 10.
Windows server 2016 is also supported.
User can also use ngnix which provides support of ASP.net applications and also support HTTP/2.
There is also new server available which is used in development time which is called Kestrel again cross platform by micro soft which does not provide support for HTTP/2 in version 1.
Hosting Java Apps
Hosting Java applications which is always supports Apache HTTP 2.4.
Which also supports Jetty by the servlet container and user can host the applications by using Jetty 9.3+.
Which is also provides supporting of Tomcat 9.
Hosting Node Apps
node-http2 package provides some support of HTTP/2.
node-spdy provide support of HTTP/2 and SPDY protocol.
Expressjs 5.0 have some support but at the time of producing the content their seems to be some issues.
Client side Libraries
Description
Libraries can be divided into Client side libraries and Server side libraries. Now here explained about the client side libraries. Now depending on the platform there are different options are available. On the JVM platform one of the best known open source project which provides low level support to the sockets and HTTP and HTTP/2 which Netty.
In the JVM there is an another library which is Jetty which is very nice and clean client library.
OKHTTP which provides are disable of HTTP/2.
HTTP/2 which support the all the HTTP/2 connections.
node-http2 which is available on node.
nghttp2 which is used as a server which also client proxy and consumed it as a library.
HTTP/2 on JVM
In order to use HTTP/2 couple of imports and things take into consideration.
Initially user need to have the JDK 8 and upwards required.
User need to use ALPN extension which stands for Application Layer Protocol Negotiation extensions and provide it in the class path.
User need to include the JDK 9.
Now the code below demonstrates the how to interact with the HTTP/2 server by using the high level i.e same semantics which are used in HTTP 1.1 and here using OKHTTP and the okhttp.jar file from the OKHTTP .
[c]
import okhttp3.OKHttpClient;
import okhttp3.Request;
import okhttep.Response;
import java.io.IOException;
public class HighLevelClient {
public static void main (String[] args) throws IOException {
OKHttpClient client = new OKHttpClient();
Request.Builder builder = new Request.Builder();
Request request = buider.url("https://http2.golang.org")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
[/c]
User can run the above the user can get the output as Congratulations you're using HTTP/2 right now as shown in below image.
Summary
Key Points
HTTP/2 host several applications.
Jetty is an another library in client side libraries.