diff options
author | Luca Andreatta | 2018-12-13 14:25:45 +0000 |
---|---|---|
committer | Thomas Wolf | 2018-12-14 20:48:26 +0000 |
commit | 03f87a38a842acf0f2958ef41d5dc34936eff074 (patch) | |
tree | c5e81e79bfe1b6af1aaba032c74456050730a2be /org.eclipse.egit.github.core | |
parent | 25146a4a310ad6206ff517841afba78d58134746 (diff) | |
download | egit-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
Diffstat (limited to 'org.eclipse.egit.github.core')
-rw-r--r-- | org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java | 21 |
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 |