2002/05/28 17:50:24
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:47:33 +0000 (06:47 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:47:33 +0000 (06:47 +0000)
darcs-hash:20040130064733-2ba56-2b813f43cdf56fc565efe2e017d44f4bfaada5fd.gz

CHANGES
src/org/xwt/HTTP.java

diff --git a/CHANGES b/CHANGES
index 7161c89..1ffcebb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 
 18-May megacz JSObject.java: fixed a public/private bug
 
+28-May megacz HTTP.java: ugly hack to cope with Microsoft CARP PAC scripts
+
index 52de898..7fa5e3c 100644 (file)
@@ -420,6 +420,24 @@ public class HTTP {
                 while((s = br.readLine()) != null) script += s + "\n";
                 if (Log.on) Log.log(HTTP.ProxyInfo.class, "successfully retrieved WPAD PAC:");
                 if (Log.on) Log.log(HTTP.ProxyInfo.class, script);
+                
+                // MS CARP hack
+                Vector carpHosts = new Vector();
+                for(int i=0; i<script.length(); i++)
+                    if (script.regionMatches(i, "new Node(", 0, 9)) {
+                        String host = script.substring(i + 10, script.indexOf('\"', i + 11));
+                        if (Log.on) Log.log(HTTP.ProxyInfo.class, "Detected MS Proxy Server CARP Script, Host=" + host);
+                        carpHosts.addElement(host);
+                    }
+                if (carpHosts.size() > 0) {
+                    script = "function FindProxyForURL(url, host) {\nreturn \"";
+                    for(int i=0; i<carpHosts.size(); i++)
+                        script += "PROXY " + carpHosts.elementAt(i) + "; ";
+                    script += "\";\n}";
+                    if (Log.on) Log.log(HTTP.ProxyInfo.class, "DeCARPed PAC script:");
+                    if (Log.on) Log.log(HTTP.ProxyInfo.class, script);
+                }
+
                 Script scr = cx.compileReader(proxyAutoConfigRootScope, new StringReader(script), "PAC script at " + url, 0, null);
                 scr.exec(cx, proxyAutoConfigRootScope);
                 return (Function)proxyAutoConfigRootScope.get("FindProxyForURL", null);