From fa12ef388ec82f0641467828df27a1d1f60af7f4 Mon Sep 17 00:00:00 2001 From: Melloware Date: Wed, 18 Sep 2024 10:26:36 -0400 Subject: [PATCH] Fix #766: ProxyOptions for Vert.X Downloader (#767) --- .../frontend/lib/VertxFileDownloader.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/deployment/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/VertxFileDownloader.java b/deployment/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/VertxFileDownloader.java index 76d3d198..98943284 100644 --- a/deployment/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/VertxFileDownloader.java +++ b/deployment/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/VertxFileDownloader.java @@ -17,6 +17,7 @@ import io.vertx.core.buffer.Buffer; import io.vertx.core.file.AsyncFile; import io.vertx.core.file.OpenOptions; +import io.vertx.core.net.ProxyOptions; import io.vertx.ext.web.client.HttpRequest; import io.vertx.ext.web.client.HttpResponse; import io.vertx.ext.web.client.WebClient; @@ -31,11 +32,31 @@ public class VertxFileDownloader implements FileDownloader { public VertxFileDownloader(Vertx vertx) { this.vertx = vertx; - webClient = WebClient.create(vertx, new WebClientOptions() + + String proxyHost = System.getProperty("http.proxyHost"); + String proxyPort = System.getProperty("http.proxyPort"); + String proxyUser = System.getProperty("http.proxyUser"); + String proxyPassword = System.getProperty("http.proxyPassword"); + + WebClientOptions options = new WebClientOptions() .setSsl(true) .setFollowRedirects(true) .setTrustAll(true) - .setKeepAlive(true)); + .setKeepAlive(true); + + // Set the proxy if it's configured + if (proxyHost != null && proxyPort != null) { + options.setProxyOptions(new ProxyOptions() + .setHost(proxyHost) + .setPort(Integer.parseInt(proxyPort))); + + // Optionally, add authentication + if (proxyUser != null && proxyPassword != null) { + options.getProxyOptions().setUsername(proxyUser).setPassword(proxyPassword); + } + } + + this.webClient = WebClient.create(vertx, options); } public void download(String downloadUrl, String destination, String userName, String password) throws DownloadException {