HTTP Clients

Supports calling external HTTP services by a common client API. The API is defined by two interfaces HTTPClient and HTTPResponse. To create an implementation of the HTTPClient we’re offering a factory through HTTPClientFinder.





Main approach to get a http client is through the client factory. That one can be retrived through HTTPClientFinder. Here is the easiest way:

HTTPClient client = HTTPClientFinder.createClient();

You could also get a specific behavior:

HTTPClient client = HTTPClientFinder.createClient(HTTPConnectionPooling.class);

To get a specific client:

HTTPClient client = HTTPClientFinder.createClient(new Hints(Hints.HTTP_CLIENT,

For a test case it is possible to set a MockingHttpClientFactory to avoid network traffic. The factory will present a client that is suitable for the specific need in the test. The code could look like:

 public void testThatCallsgetHttpClientFactory() throws Exception {

     Hints.putSystemDefault(Hints.HTTP_CLIENT_FACTORY, MockingHttpClientFactory.class);
     try {
         HTTPClient client = HTTPClientFinder.createClient();
     } finally {

System property

The client can also be set through system property at the command line:

java -Dorg.geotools.http.client=org.geotools.http.CustomHttpClient ....