Skip to content

Commit

Permalink
spotify#890 fix for proxy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
deki committed Jan 25, 2018
1 parent d5d3bf9 commit 948fa08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private ClientConfig updateProxy(ClientConfig config, Builder builder) {
final String proxyHost = System.getProperty("http.proxyHost");
if (proxyHost != null) {
String proxyPort = checkNotNull(System.getProperty("http.proxyPort"), "http.proxyPort");
config.property(ClientProperties.PROXY_URI, !proxyHost.startsWith("http") ? "http://" : ""
config.property(ClientProperties.PROXY_URI, (!proxyHost.startsWith("http") ? "http://" : "")
+ proxyHost + ":" + proxyPort);

//ensure Content-Length is populated before sending request via proxy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ public void testHostForIpHttps() {
assertThat(client.getHost(), equalTo("192.168.53.103"));
}

@Test
public void testHostWithProxy() {
try {
System.setProperty("http.proxyHost", "gmodules.com");
System.setProperty("http.proxyPort", "80");
final DefaultDockerClient client = DefaultDockerClient.builder()
.uri("https://192.168.53.103:2375").build();
assertThat((String) client.getClient().getConfiguration().getProperty("jersey.config.client.proxy.uri"),
equalTo("http://gmodules.com:80"));
} finally {
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
}
}

private RecordedRequest takeRequestImmediately() throws InterruptedException {
return server.takeRequest(1, TimeUnit.MILLISECONDS);
}
Expand Down

0 comments on commit 948fa08

Please sign in to comment.