Skip to content

nhenneaux/jersey-httpclient-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jersey Connector with java.net.http.HttpClient

A Jersey connector using java.net.http.HttpClient and supporting HTTP/1.1 and HTTP/2.0 with the same client. The protocol is selected based on the server capabilities.

Usage

To build a JAX-RS client, you can use the following.

var client = ClientBuilder.newClient(new ClientConfig().connectorProvider(HttpClientConnector::new))

If you want to customise the Java HTTP client you are using, you can use the following.

var httpClient = HttpClient.newHttpClient();
var client = ClientBuilder.newClient(
                            new ClientConfig()
                              .connectorProvider(
                                 (jaxRsClient, config) ->  new HttpClientConnector(httpClient)))

Inspired from Stackoverflow question without answer Support HTTP/1.1 and HTTP/2 with a JAX-RS client.

Version 0.3 is compatible with Jersey 2 while version 1.1 uses Jersey 3.

Build Status Maven Central Quality Gate Status Coverage