1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Reformat the httpProxy patch.

This commit is contained in:
Cedric Beust 2016-12-06 14:44:13 -08:00
parent 160d955a32
commit 387b3b4c2e

View file

@ -433,13 +433,19 @@ public class Main {
} }
private Proxy getProxy() { private Proxy getProxy() {
String http_proxy = System.getenv("http_proxy"); String httpProxy = System.getenv("http_proxy");
try { try {
String host = http_proxy == null || http_proxy.indexOf(':') == -1 ? "localhost" : http_proxy.substring(0, http_proxy.indexOf(':')); String host = httpProxy == null || httpProxy.indexOf(':') == -1
int port = http_proxy == null || http_proxy.indexOf(':') == -1 ? 0 : Integer.parseInt(http_proxy.substring(http_proxy.indexOf(':') + 1)); ? "localhost"
return http_proxy == null ? null : new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)); : httpProxy.substring(0, httpProxy.indexOf(':'));
int port = httpProxy == null || httpProxy.indexOf(':') == -1
? 0
: Integer.parseInt(httpProxy.substring(httpProxy.indexOf(':') + 1));
return httpProxy == null
? null
: new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
log(1, "Warning: invalid proxy port: " + http_proxy);; log(1, "Warning: invalid proxy port: " + httpProxy);;
return null; return null;
} }
} }