Folks,

here is a patch for org.apache.commons.httpclient.contrib.proxy.PluginProxyUtil that allows detection of proxy settings in a browser (applet) for JDK 1.5 and 1.6. It's actually using existing logic, just enables it for JDK1.5 and JDK1.6.

Thanks for the essential piece of software, which httpclient surely is!

Jiri Kopsa
--- c:/PluginProxyUtil.java     2006-10-29 20:47:39.875000000 +0100
+++ d:/PluginProxyUtil.java     2006-10-29 20:57:26.515625000 +0100
@@ -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]

Reply via email to