1. Official feature
110:http 2 Client
2. Instructions for use
HTTP, the Protocol for transmitting web pages, was adopted in the current 1.1 version as early as 1997. It was not until 2015 that HTTP2 became a standard.
The main difference between http/1.1 and HTTP/2 is how to build and transfer data between the client and the server. The http/1.1 relies on the request/response cycle. HTTP/2 allows the server to "push" data: It can send more data than the client requests. This allows it to prioritize and send data that is critical to loading the page first.
There are new ways to handle HTTP calls in Java 9. It provides a new HTTP client (HttpClient), which will override the HttpURLConnection for blocking mode only (HttpURLConnection was created in the HTTP1.0 era and used a protocol-agnostic approach) and provided support for WebSocket and HTTP/2.
In addition, HTTP clients provide APIs to handle the features of HTTP/2, such as streaming and server push.
The new HTTP client API can be obtained from the Jdk.incubator.httpclient module. Because, by default, this module is not available according to Classpath, you need to use the add
The modules command option configures this module to add the module to the classpath.
3. Examples of Use
Example:
Still Silicon Valley interviewer Song Hongkang
Links: https://www.jianshu.com/p/0945ccb8677f
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
JAVA9 new features -15-new HTTP Client API