Skip to content
Roar Brænden edited this page Jan 25, 2021 · 13 revisions

Description

We have some duplication between modules implementing their own HTTPClient interface (in order to switch between java and http commons implementations for better handling of cookies etc...). As these have been developed in isolation they often use a constructor parameter rather than the system wide factory patterns preferred by the GeoTools architecture.

This proposal combines these http client interfaces into a single api, and uses the factory pattern rather than a constructor parameter.

HTTPClient http = HTTPClientFinder.getClient();
http.setUser("test");
http.setPassword("1234");
http.setConnectionTimeout(15); // seconds
http.setReadTimeout(15); // seconds
http.setTryGzip(false);

URL url = new URL("http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities");
HTTPResponse response = http.get( url );
try (InputStream = response.getResponseStream() ){
  parsed = DocumentFactory.getInstance( inputStream );
} finally {
  response.dispose();
}

References:

Assigned to Release

GeoTools 25 series.

Status

Choose one of:

  • Under Discussion
  • In Progress
  • Completed
  • Rejected,
  • Deferred

Voting:

  • Andrea Aime: +1
  • Ian Turton: +1
  • Jody Garnett: +1
  • Nuno Oliveira:
  • Simone Giannecchini:
  • Torben Barsballe: +1

Tasks

  1. Setup gt-http module with HTTPClient interface, with gt-http-commons plugin.
  2. Migrate geotools to new interface:
    • gt-wfs-ng
    • gt-wms
    • gt-wmts
    • gt-mongodb
    • gt-tile-client
    • gt-wps
  3. Deprecate previous HTTPClient and HTTPResponse interfaces providing one release cycle for geotools users to migrate their code
  4. Documentation changes
    • API change make a note upgrading page.
    • Update the user guide with gt-http page and code example

API Change

Before:

import org.geotools.ows.wms.MultithreadedHttpClient;

capabilities.getRequest().getGetCapabilities().getGet(), new MultithreadedHttpClient(), capabilities);

After:

  <dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt-http-commons</artifactId>
    <version>${project.version}</version>
  </dependency>
import org.geotools.http.HTTPConnectionPooling;

capabilities.getRequest().getGetCapabilities().getGet(), HTTPClientFinder.getClient(HTTPConnectionPooling.class)
                                                       , capabilities);

Or:

System.setProperty("org.geotools.http.client", "org.geotools.http.MultithreadedHttpClient");

capabilities.getRequest().getGetCapabilities().getGet(), HTTPClientFinder.getClient(), capabilities);
Clone this wiki locally