Skip to content

Commit

Permalink
Fix quarkiverse#766: ProxyOptions for Vert.X Downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Sep 18, 2024
1 parent ce0b541 commit cf36b47
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit cf36b47

Please sign in to comment.