Skip to content

Commit

Permalink
Merge pull request spotify#970 from deki/890-proxy-usage
Browse files Browse the repository at this point in the history
spotify#890 fix for proxy usage ("Expected authority at index 7" error)
  • Loading branch information
davidxia authored Jan 30, 2018
2 parents b0d9a69 + c2f1b1d commit 3791a2e
Show file tree
Hide file tree
Showing 2 changed files with 17 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);
final String proxyUser = System.getProperty("http.proxyUser");
if (proxyUser != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ 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 3791a2e

Please sign in to comment.