JAVA9 new features -15-new HTTP Client API

Source: Internet
Author: User
Tags http 2

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.