Author: olegk Date: Thu Nov 2 11:16:32 2006 New Revision: 470480 URL: http://svn.apache.org/viewvc?view=rev&rev=470480 Log: Enabled detection of proxy settings in a browser (applet) for JDK 1.5 and 1.6
Contributed by Jiri Kopsa <Jiri.Kopsa at Sun.COM> Modified: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java Modified: jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java?view=diff&rev=470480&r1=470479&r2=470480 ============================================================================== --- jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java (original) +++ jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java Thu Nov 2 11:16:32 2006 @@ -107,17 +107,15 @@ if (result == null) { invokeFailover = true; } - } else if (javaVers.startsWith("1.4")) { - result = detectProxySettingsJDK14(sampleURL); + } else if (javaVers.startsWith("1.4") || (javaVers.startsWith("1.5") || javaVers.startsWith("1.6"))) { + result = detectProxySettingsJDK14_JDK15_JDK16(sampleURL); if (result == null) { invokeFailover = true; } - } else if (javaVers.startsWith("1.5")) { - invokeFailover = true; } else { if (LOG.isDebugEnabled()) { LOG.debug("Sun Plugin reported java version not 1.3.X, " + - "1.4.X or 1.5.X - trying failover detection..."); + "1.4.X, 1.5.X or 1.6.X - trying failover detection..."); } invokeFailover = true; } @@ -220,7 +218,7 @@ * @param sampleURL the URL to check proxy settings for * @return ProxyHost the host and port of the proxy that should be used */ - private static ProxyHost detectProxySettingsJDK14(URL sampleURL) { + private static ProxyHost detectProxySettingsJDK14_JDK15_JDK16(URL sampleURL) { ProxyHost result = null; try { // Look around for the 1.4.X plugin proxy detection class... @@ -232,6 +230,7 @@ new Class[] {URL.class}); Object proxyInfoArrayObj = getProxyInfoMethod.invoke(null, new Object[] {sampleURL}); + if (proxyInfoArrayObj == null || Array.getLength(proxyInfoArrayObj) == 0) { if (LOG.isDebugEnabled()) { @@ -257,6 +256,7 @@ result = new ProxyHost(proxyIP, proxyPort); } } catch (Exception e) { + e.printStackTrace(); LOG.warn("Sun Plugin 1.4.X proxy detection class not found, " + "will try failover detection, e:"+e); } @@ -325,4 +325,4 @@ } return result; } -} +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]