From 43dc92943737ef84165b13520c60ffa982e5c5c9 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:01:00 +0000 Subject: [PATCH] 2003/06/12 17:57:25 darcs-hash:20040130070100-2ba56-d0f08a533d6e7323dd9e39c2a2c21bd103f0d005.gz --- src/org/xwt/HTTP.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/org/xwt/HTTP.java b/src/org/xwt/HTTP.java index 44e2f72..e401f86 100644 --- a/src/org/xwt/HTTP.java +++ b/src/org/xwt/HTTP.java @@ -179,7 +179,7 @@ public class HTTP { if (Platform.detectProxy() == null) throw new HTTPException("could not resolve hostname \"" + host + "\" and no proxy configured"); if (Log.on) Log.log(this, " could not resolve host " + host + "; using xmlrpc.xwt.org to ensure security"); try { - JS.Array args = new JS.Array(); + Array args = new Array(); args.addElement(host); Object ret = new XMLRPC("http://xmlrpc.xwt.org/RPC2/", "dns.resolve").call(args); if (ret == null || !(ret instanceof String)) throw new Exception(" xmlrpc.xwt.org returned non-String: " + ret); @@ -281,14 +281,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.Function pacFunc) { - throw new Error("not implemented"); - // FIXME - /* + public Socket attemptPAC(org.xwt.js.JS.Callable pacFunc) { if (Log.verbose) Log.log(this, "evaluating PAC script"); String pac = null; try { - Object obj = pacFunc.call(Proxy.proxyAutoConfigRootScope, null, new Object[] { url.toString(), url.getHost() }); + org.xwt.js.Array args = new org.xwt.js.Array(); + args.addElement(url.toString()); + args.addElement(url.getHost()); + Object obj = pacFunc.call(args); if (Log.verbose) Log.log(this, " PAC script returned \"" + obj + "\""); pac = obj.toString(); } catch (Throwable e) { @@ -317,7 +317,6 @@ public class HTTP { } if (Log.on) Log.log(this, "all PAC results exhausted"); return null; - */ } @@ -511,14 +510,16 @@ public class HTTP { try { if (length == 0 && contentLength == -1) { readChunk(); - if (chunkedDone) return -1; + if (chunkedDone) { good = true; return -1; } } else { - if (length == 0) return -1; + if (length == 0) { good = true; return -1; } } if (len > length) len = length; int ret = super.read(b, off, len); - length -= ret; - good = true; + if (ret >= 0) { + length -= ret; + good = true; + } return ret; } finally { if (!good) invalid = true; -- 1.7.10.4