Skip to content

Commit e4deed8

Browse files
authored
Fix #992 Automatically resolve the proxy URL by HTTP_PROXY env variable (#1003)
1 parent 544a44a commit e4deed8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

slack-api-client/src/main/java/com/slack/api/SlackConfig.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public SlackConfig() {
172172
private String proxyUrl = initProxyUrl();
173173

174174
// This method runs only once when instantiating this object.
175-
// If you want to reflect dynamically updated system properties,
175+
// If you want to reflect dynamically updated system properties or env variables,
176176
// create a new instance by invoking the default constructor.
177177
private static String initProxyUrl() {
178178
String host = System.getProperty("http.proxyHost");
@@ -194,6 +194,14 @@ private static String initProxyUrl() {
194194
return "http://" + host;
195195
}
196196
}
197+
String httpsEnvProxyUrl = System.getenv("HTTPS_PROXY");
198+
if (httpsEnvProxyUrl != null && !httpsEnvProxyUrl.trim().isEmpty()) {
199+
return httpsEnvProxyUrl;
200+
}
201+
String httpEnvProxyUrl = System.getenv("HTTP_PROXY");
202+
if (httpEnvProxyUrl != null && !httpEnvProxyUrl.trim().isEmpty()) {
203+
return httpEnvProxyUrl;
204+
}
197205
return null;
198206
}
199207

0 commit comments

Comments
 (0)