From 3a825db9ce7a1a326dfc6dd37cecf245eb64054d Mon Sep 17 00:00:00 2001 From: Lucas Burson Date: Sun, 2 Apr 2023 16:46:04 -0500 Subject: [PATCH] Set 'useSystemProperties' on HttpClient builder Set the httpClientBuilder.useSystemProperties() so that users may set the proxy settings via system properties eg ``` -Djava.net.useSystemProxies=true -Dhttp.proxyHost=PROXY_HOST -Dhttp.proxyPort=PROXY_PORT -Dhttp.proxyUser=USERNAME -Dhttp.proxyPassword=PASSWORD ``` --- .github/workflows/pull-request.yml | 2 +- src/main/java/org/maproulette/client/http/HttpResource.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4415e72..5973f3e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest services: postgis11: - image: postgis/postgis:11-2.5 + image: postgis/postgis:13-3.3 ports: - 5432:5432 env: diff --git a/src/main/java/org/maproulette/client/http/HttpResource.java b/src/main/java/org/maproulette/client/http/HttpResource.java index 7247852..e76a17a 100644 --- a/src/main/java/org/maproulette/client/http/HttpResource.java +++ b/src/main/java/org/maproulette/client/http/HttpResource.java @@ -141,7 +141,9 @@ private InputStream response() throws MapRouletteException final var target = new HttpHost(this.uri.getHost(), this.uri.getPort(), this.uri.getScheme()); final var context = HttpClientContext.create(); - final var clientBuilder = HttpClients.custom(); + // Create a builder that supports reading from system properties so things like + // proxies can be used with -Dhttp.proxyHost, -Dhttp.proxyPort. + final var clientBuilder = HttpClients.custom().useSystemProperties(); if (this.creds != null) { final var credsProvider = new BasicCredentialsProvider();