JEP 110: HTTP 2 Client

OwnerMichael McMahon
Created2014/05/12 16:26
Updated2014/09/26 05:37
Componentcore-libs /
Discussionnet dash dev at openjdk dot java dot net
Reviewed byAlan Bateman
Endorsed byBrian Goetz


Define and implement a new Http client API to eventually replace the legacy HttpURLConnection and which also implements HTTP 2.0 and websockets.


Problems with the existing API and implementation:


Non goals

While this API is intended to replace the URLConnection API for new code, it is not intended to immediately re-implement the old API using the new API/implementation. This may happen as future work.

These are also some requirements which had been considered in JDK 8, but in the interests of keeping the API as simple as possible, are being left out for JDK 9. Some of these will assume less importance with the gradual adoption of http 2.0 eg. connection caching because there is less requirement for multiple TCP connections with Http 2.0.


Some prototyping work was done during JDK 8 and separate classes were defined for the http client, requests and responses. The builder pattern was used to separate mutable entities from the immutable products. The prototype was built on NIO AsynchronousSocketChannels and that API will be the starting point for this work. It is expected that the API will undergo a number of iterations before being finalised. The API/implementation was also standalone, ie. existing stack will be left as is to ensure compatibility and allow a phased approach (don't have to support everything at once).

The prototype API also included support for:


A number of existing Http client API and implementations exist: for example Jetty (org.mortbay.jetty) and the Apache Http client.

Both of these are both rather heavy-weight in terms of numbers of packages and classes and don't take advantage of newer language features like lambdas.

Risks and Assumptions

Https 2.0 support depends on TLS ALPN (Application Layer Negotiation Extension) which is not currently supported in JDK.

The Http 2.0 spec itself is still in internet-draft form, but is expected to be submitted as a draft standard Nov 2014.


Will need new tests. The internal http server will provide a suitable test harness for regression tests and TCK tests. SQE tests could use it also, but may need to test against real http servers.