changes made after tupshins reconstruction
[org.ibex.core.git] / src / org / xwt / HTTP.java
index a3525e4..427fc70 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
 package org.xwt;
 
 import java.net.*;
@@ -339,7 +339,7 @@ public class HTTP {
         OUTER: do {
             if (pi != null) {
                 for(int i=0; i<pi.excluded.length; i++) if (host.equals(pi.excluded[i])) break OUTER;
-                if (sock == null && pi.proxyAutoConfigJSFunction != null) sock = attemptPAC(pi.proxyAutoConfigJSFunction);
+                if (sock == null && pi.proxyAutoConfigFunction != null) sock = attemptPAC(pi.proxyAutoConfigFunction);
                 if (sock == null && ssl && pi.httpsProxyHost != null) sock = attemptHttpProxy(pi.httpsProxyHost,pi.httpsProxyPort);
                 if (sock == null && pi.httpProxyHost != null) sock = attemptHttpProxy(pi.httpProxyHost, pi.httpProxyPort);
                 if (sock == null && pi.socksProxyHost != null) sock = attemptSocksProxy(pi.socksProxyHost, pi.socksProxyPort);
@@ -658,7 +658,7 @@ public class HTTP {
         public String socksProxyHost = null;                 ///< the SOCKS Proxy Host to use
         public int socksProxyPort = -1;                      ///< the SOCKS Proxy Port to use
         public String[] excluded = null;                     ///< hosts to be excluded from proxy use; wildcards permitted
-        public JSFunction proxyAutoConfigJSFunction = null;  ///< the PAC script
+        public JS proxyAutoConfigFunction = null;  ///< the PAC script
     
         public static Proxy detectProxyViaManual() {
             Proxy ret = new Proxy();
@@ -713,8 +713,8 @@ public class HTTP {
             return ret;
         }
     
-        public static JSScope proxyAutoConfigRootJSScope = new ProxyAutoConfigRootJSScope();
-        public static JSFunction getProxyAutoConfigJSFunction(String url) {
+        public static JSScope proxyAutoConfigRootScope = new ProxyAutoConfigRootScope();
+        public static JS getProxyAutoConfigFunction(String url) {
             try { 
                 BufferedReader br = new BufferedReader(new InputStreamReader(new HTTP(url, true).GET()));
                 String s = null;
@@ -740,9 +740,9 @@ public class HTTP {
                     if (Log.on) Log.info(Proxy.class, script);
                 }
 
-                JSFunction scr = JSFunction.fromReader("PAC script at " + url, 0, new StringReader(script));
-                scr.cloneWithNewParentScope(proxyAutoConfigRootJSScope).call(null, null, null, null, 0);
-                return (JSFunction)proxyAutoConfigRootJSScope.get("FindProxyForURL");
+                JS scr = JS.fromReader("PAC script at " + url, 0, new StringReader(script));
+                JS.cloneWithNewParentScope(scr, proxyAutoConfigRootScope).call(null, null, null, null, 0);
+                return (JS)proxyAutoConfigRootScope.get("FindProxyForURL");
             } catch (Exception e) {
                 if (Log.on) {
                     Log.info(Platform.class, "WPAD detection failed due to:");
@@ -781,8 +781,8 @@ public class HTTP {
                 Scheduler.add(new Scheduler.Task() {
                         public void perform() throws Exception {
                             Box b = new Box();
-                            Template t = Template.getTemplate((Res)Main.builtin.get("org/xwt/builtin/proxy_authorization.xwt"));
-                            t.apply(b, null);
+                            Template t = Template.buildTemplate(Stream.getInputStream((JS)Main.builtin.get("org/xwt/builtin/proxy_authorization.xwt")), new XWT(null));
+                            t.apply(b);
                             b.put("realm", realm);
                             b.put("proxyIP", proxyIP);
                         }
@@ -796,9 +796,9 @@ public class HTTP {
 
         // ProxyAutoConfigRootJSScope ////////////////////////////////////////////////////////////////////
 
-        public static class ProxyAutoConfigRootJSScope extends JSScope.Global {
+        public static class ProxyAutoConfigRootScope extends JSScope.Global {
 
-            public ProxyAutoConfigRootJSScope() { super(); }
+            public ProxyAutoConfigRootScope() { super(); }
         
             public Object get(Object name) throws JSExn {
                 //#switch(name)