public void activate ( InetAddress host , int port , Collection < String > nonProxyHosts ) { for ( String scheme : new String [ ] { "http" , "https" } ) { String currentProxyHost = System . getProperty ( scheme + ".proxyHost" ) ; String currentProxyPort = System . getProperty ( scheme + ".proxyPort" ) ; if ( currentProxyHost != null ) { originalProxies . put ( scheme , new InetSocketAddress ( currentProxyHost , Integer . parseInt ( currentProxyPort ) ) ) ; } System . setProperty ( scheme + ".proxyHost" , new InetSocketAddress ( host , port ) . getHostString ( ) ) ; System . setProperty ( scheme + ".proxyPort" , Integer . toString ( port ) ) ; } String currentNonProxyHosts = System . getProperty ( "http.nonProxyHosts" ) ; if ( currentNonProxyHosts == null ) { originalNonProxyHosts . clear ( ) ; } else { for ( String nonProxyHost : Splitter . on ( ' ' ) . split ( currentNonProxyHosts ) ) { originalNonProxyHosts . add ( nonProxyHost ) ; } } System . setProperty ( "http.nonProxyHosts" , Joiner . on ( ' ' ) . join ( nonProxyHosts ) ) ; }
Activates a proxy override for the given URI scheme .