Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Andreatta2018-12-13 09:25:45 -0500
committerThomas Wolf2018-12-14 15:48:26 -0500
commit03f87a38a842acf0f2958ef41d5dc34936eff074 (patch)
treec5e81e79bfe1b6af1aaba032c74456050730a2be
parent25146a4a310ad6206ff517841afba78d58134746 (diff)
downloadegit-github-03f87a38a842acf0f2958ef41d5dc34936eff074.tar.gz
egit-github-03f87a38a842acf0f2958ef41d5dc34936eff074.tar.xz
egit-github-03f87a38a842acf0f2958ef41d5dc34936eff074.zip
GitHubClient: enable using a proxy
Adds the possibility to use a proxy in the GitHubClient. Bug: 541603 Signed-off-by: Luca Andreatta <luca.andreatta@eng.it> Change-Id: Ib706a15ec4dbd003692215d9e7b0bf2668604aee
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
index caf08167..4ac386bb 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -46,6 +46,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
+import java.net.Proxy;
import java.net.URL;
import org.eclipse.egit.github.core.RequestError;
@@ -146,6 +147,8 @@ public class GitHubClient {
private String credentials;
+ private Proxy proxy;
+
private String userAgent = USER_AGENT;
private String headerAccept = ACCEPT_FULL;
@@ -287,6 +290,11 @@ public class GitHubClient {
*/
protected HttpURLConnection createConnection(String uri) throws IOException {
URL url = new URL(createUri(uri));
+
+ if (proxy != null) {
+ return (HttpURLConnection) url.openConnection(proxy);
+ }
+
return (HttpURLConnection) url.openConnection();
}
@@ -368,6 +376,19 @@ public class GitHubClient {
}
/**
+ * Set a proxy to use for HTPPS connections through this client.
+ *
+ * @param proxy
+ * to set; may be {@code null}, in which case no proxy is used
+ * @return this client
+ * @since 5.3
+ */
+ public GitHubClient setProxy(Proxy proxy) {
+ this.proxy = proxy;
+ return this;
+ }
+
+ /**
* Set OAuth2 token
*
* @param token

Back to the top