Support HTTP/1.1 and HTTP/2 with a JAX-RS client

Nicolas Henneaux :

I want to implement a JAX-RS client that support HTTP/1.1 and HTTP/2 for a JAX-RS client.

The idea is to use HTTP/2 if the server supports ALPN with HTTP/2 and uses HTTP/1.1 if the server does not provide any information.

I have read some articles about ALPN and it seems to be possible but I don't find anything supporting these protocol at the same time. I did not manage to plug these together.

I am currently using the Jetty HTTP/1.1 transport connector for Jersey and a custom implementation for HTTP/2 transport connector.

Nicolas Henneaux :

Java HTTP client provided with Java 11 is supporting HTTP/1.1 and HTTP/2 (see Introduction to the Java HTTP Client).

I have built a connector using it Jersey Connector using java.net.http.HttpClient. You can use it adding the following dependency.

<dependency>
  <groupId>com.github.nhenneaux.jersey.connector.httpclient</groupId>
  <artifactId>jersey-httpclient-connector</artifactId>
  <version>0.1.1</version>
</dependency>

Maven Central

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=446631&siteId=1