X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnet%2FHTTP.java;h=3c2d9707f31706a9e57570a15828cbacca2c3d48;hp=0142a9e743911102568869ecc58d4573d23c4161;hb=76982fccac3c46ccc47621dd22dc0c96b6b9cd62;hpb=8e190fb0ff508ccf4962bbfbf8295a431805c12b diff --git a/src/org/ibex/net/HTTP.java b/src/org/ibex/net/HTTP.java index 0142a9e..3c2d970 100644 --- a/src/org/ibex/net/HTTP.java +++ b/src/org/ibex/net/HTTP.java @@ -180,8 +180,8 @@ public class HTTP { /** Attempts a direct connection */ private Socket attemptDirect() { try { - if (Log.verbose) Log.info(this, "attempting to create unproxied socket to " + - host + ":" + port + (ssl ? " [ssl]" : "")); + Log.info(this, "attempting to create unproxied socket to " + + host + ":" + port + (ssl ? " [ssl]" : "")); return getSocket(host, port, ssl, true); } catch (IOException e) { if (Log.on) Log.info(this, "exception in attemptDirect(): " + e); @@ -271,9 +271,9 @@ public class HTTP { if (Log.verbose) Log.info(this, "evaluating PAC script"); String pac = null; try { - Object obj = pacFunc.call(url, host, null, null, 2); - if (Log.verbose) Log.info(this, " PAC script returned \"" + obj + "\""); - pac = obj.toString(); + JS obj = pacFunc.call(JS.S(url), JS.S(host), null, null, 2); + if (Log.verbose) Log.info(this, " PAC script returned \"" + JS.debugToString(obj) + "\""); + pac = JS.toString(obj); } catch (Throwable e) { if (Log.on) Log.info(this, "PAC script threw exception " + e); return null; @@ -328,7 +328,7 @@ public class HTTP { throw new IOException("HTTP only supports http/https urls"); } if (url.indexOf("://") == -1) throw new IOException("URLs must contain a ://"); - String temphost = url.substring(url.indexOf("://") + 1); + String temphost = url.substring(url.indexOf("://") + 3); path = temphost.substring(temphost.indexOf('/')); temphost = temphost.substring(0, temphost.indexOf('/')); if (temphost.indexOf(':') != -1) { @@ -380,7 +380,6 @@ public class HTTP { if (authCache.get(originalUrl) != null) pw.print("Authorization: " + authCache.get(originalUrl) + "\r\n"); pw.print(content == null ? "\r\n" : content); - pw.print("\r\n"); pw.flush(); } @@ -719,7 +718,7 @@ public class HTTP { return ret; } - public static JSScope proxyAutoConfigRootScope = new ProxyAutoConfigRootScope(); + public static JSScope proxyAutoConfigRootScope = /*new ProxyAutoConfigRootScope();*/ null; // FIXME: New api public static JS getProxyAutoConfigFunction(String url) { try { BufferedReader br = new BufferedReader(new InputStreamReader(new HTTP(url, true).GET())); @@ -748,7 +747,7 @@ public class HTTP { 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"); + return (JS)proxyAutoConfigRootScope.get(JS.S("FindProxyForURL")); } catch (Exception e) { if (Log.on) { Log.info(Platform.class, "WPAD detection failed due to:"); @@ -791,8 +790,8 @@ public class HTTP { // FIXME //Template.buildTemplate("org/ibex/builtin/proxy_authorization.ibex", Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), new Ibex(null)); t.apply(b); - b.put("realm", realm); - b.put("proxyIP", proxyIP); + b.put(JS.S("realm"), JS.S(realm)); + b.put(JS.S("proxyIP"), JS.S(proxyIP)); } }); @@ -804,7 +803,8 @@ public class HTTP { // ProxyAutoConfigRootJSScope //////////////////////////////////////////////////////////////////// - public static class ProxyAutoConfigRootScope extends JSScope.Global { + // FIXME: JS Update for new API + /*public static class ProxyAutoConfigRootScope extends JSScope.Global { public ProxyAutoConfigRootScope() { super(); } @@ -827,7 +827,7 @@ public class HTTP { return super.get(name); } - private static final JS proxyConfigBindings = new JS(); + private static final JS proxyConfigBindings = new JS.O(); private static final JS ProxyConfig = new JS() { public Object get(Object name) { if (name.equals("bindings")) return proxyConfigBindings; @@ -916,7 +916,7 @@ public class HTTP { return false; } public static String[] days = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; - } + }*/ /**