From 1e88f9e6eb58e2fbbf10fc6026fb859e06c4df89 Mon Sep 17 00:00:00 2001 From: Hakim Lahlou Date: Tue, 8 Feb 2022 10:05:56 -0800 Subject: [PATCH] added a new constructor that includes proxy val --- .../java/cc/protea/util/http/Request.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/cc/protea/util/http/Request.java b/src/main/java/cc/protea/util/http/Request.java index f444597..14df820 100644 --- a/src/main/java/cc/protea/util/http/Request.java +++ b/src/main/java/cc/protea/util/http/Request.java @@ -10,6 +10,7 @@ import java.lang.reflect.Modifier; import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.Proxy; import java.net.URL; import java.util.Arrays; import java.util.HashMap; @@ -66,6 +67,25 @@ public Request(final String url) { } } + /** + * The Constructor takes the url as a String and a proxy as a Proxy. + * + * @param url + * The url parameter does not need the query string parameters if they are going to be supplied via calls to + * {@link #addQueryParameter(String, String)}. You can, however, supply the query parameters in the URL if you wish. + * @param proxy + * The Connection's Proxy value + * + */ + public Request(final String url, final Proxy proxy) { + try { + this.url = new URL(url); + this.connection = (HttpURLConnection) this.url.openConnection(proxy); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + /** * Adds a Query Parameter to a list. The list is converted to a String and appended to the URL when the Request is submitted. *