Skip to content

Commit

Permalink
Allow the client to explicitly control proxy
Browse files Browse the repository at this point in the history
Fixes issue #109.
  • Loading branch information
kohsuke committed Feb 15, 2015
1 parent d90adfa commit 7bbe0f7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/org/kohsuke/github/GitHubBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.util.Map;
import java.util.Properties;

Expand Down Expand Up @@ -153,6 +156,19 @@ public GitHubBuilder withConnector(HttpConnector connector) {
return this;
}

/**
* Configures {@linkplain #withConnector(HttpConnector) connector}
* that uses HTTP library in JRE but use a specific proxy, instead of
* the system default one.
*/
public GitHubBuilder withProxy(final Proxy p) {
return withConnector(new HttpConnector() {
public HttpURLConnection connect(URL url) throws IOException {
return (HttpURLConnection) url.openConnection(p);
}
});
}

public GitHub build() throws IOException {
return new GitHub(endpoint, user, oauthToken, password, connector);
}
Expand Down

0 comments on commit 7bbe0f7

Please sign in to comment.