out = sock.getOutputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(out));
pw.print("POST " + path + " HTTP/1.0\r\n");
- pw.print("Host: " + host + "\r\n");
pw.print("User-Agent: XWT\r\n");
pw.print("Content-length: " + contentLength + "\r\n");
pw.print(headers);
} else {
PrintWriter pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()));
pw.print("GET " + path + " HTTP/1.0\r\n");
- pw.print("Host: " + host + "\r\n");
+ System.out.println("GET " + path + " HTTP/1.0\r\n");
pw.print("User-Agent: XWT\r\n");
pw.print(headers);
pw.print("\r\n");
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);