HTTP2 - SPLessons

HTTP2 Client Side Libraries

Home > Lesson > Chapter 12
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

HTTP2 Client Side Libraries

HTTP2 Client Side Libraries

shape Introduction

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

shape 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 Hosting Java Apps Hosting Node Apps

Client side Libraries

shape 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. HTTP/2 on JVM 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

shape Key Points

  • HTTP/2 host several applications.
  • Jetty is an another library in client side libraries.
  • User need to use the ALPN in class path.