X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FHTTP.java;h=4853a13b907c8d33984e8555f70e8d3ae2df1052;hb=8c1756ef3fd42cc2f324baf47e13a83f51045efe;hp=eca310fd2e720af93ea47b919e6f39ef16cf340c;hpb=4444c6057bb0cee5d2ae5a55b3045fd8eb790295;p=org.ibex.core.git diff --git a/src/org/xwt/HTTP.java b/src/org/xwt/HTTP.java index eca310f..4853a13 100644 --- a/src/org/xwt/HTTP.java +++ b/src/org/xwt/HTTP.java @@ -188,11 +188,18 @@ public class HTTP { // Methods to attempt socket creation ///////////////////////////////////////////////////////////////// + private Socket getSocket(String host, int port, boolean ssl, boolean negotiate) throws IOException { + Socket ret = ssl ? new TinySSL(host, port, negotiate) : new Socket(java.net.InetAddress.getByName(host), port); + ret.setTcpNoDelay(true); + return ret; + } + + /** Attempts a direct connection */ public Socket attemptDirect() { try { if (Log.verbose) Log.log(this, "attempting to create unproxied socket to " + host + ":" + port + (ssl ? " [ssl]" : "")); - return Platform.getSocket(host, port, ssl, true); + return getSocket(host, port, ssl, true); } catch (IOException e) { if (Log.on) Log.log(this, "exception in attemptDirect(): " + e); return null; @@ -204,7 +211,7 @@ public class HTTP { try { if (Log.verbose) Log.log(this, "attempting to create HTTP proxied socket using proxy " + proxyHost + ":" + proxyPort); - Socket sock = Platform.getSocket(proxyHost, proxyPort, ssl, false); + Socket sock = getSocket(proxyHost, proxyPort, ssl, false); if (!ssl) { if (!path.startsWith("http://")) path = "http://" + host + ":" + port + path; } else { @@ -240,7 +247,7 @@ public class HTTP { " proxied socket using proxy " + proxyHost + ":" + proxyPort); try { - Socket sock = Platform.getSocket(proxyHost, proxyPort, ssl, false); + Socket sock = getSocket(proxyHost, proxyPort, ssl, false); DataOutputStream dos = new DataOutputStream(sock.getOutputStream()); dos.writeByte(0x04); // SOCKSv4(a) @@ -276,18 +283,14 @@ public class HTTP { } /** executes the PAC script and dispatches a call to one of the other attempt methods based on the result */ - public Socket attemptPAC(org.xwt.js.JS.Callable pacFunc) { + public Socket attemptPAC(org.xwt.js.JSCallable pacFunc) { if (Log.verbose) Log.log(this, "evaluating PAC script"); String pac = null; try { - org.xwt.js.JS.Array args = new org.xwt.js.JS.Array(); - args.addElement(url.toString()); - args.addElement(url.getHost()); - /* FIXME - Object obj = pacFunc.call(args); + org.xwt.js.JSArray args = new org.xwt.js.JSArray(); + Object obj = pacFunc.call(url.toString(), url.getHost(), null, null, 2); if (Log.verbose) Log.log(this, " PAC script returned \"" + obj + "\""); pac = obj.toString(); - */ } catch (Throwable e) { if (Log.on) Log.log(this, "PAC script threw exception " + e); return null; @@ -358,7 +361,7 @@ public class HTTP { OUTER: do { if (pi != null) { for(int i=0; i