return;
} catch (UnknownHostException uhe) { }
- 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();
- 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);
- resolvedHosts.put(host, ret);
- return;
- } catch (Throwable e) {
- throw new HTTPException("exception while attempting to use xmlrpc.xwt.org to resolve " + host + ": " + e);
- }
+ if (Platform.detectProxy() == null)
+ throw new HTTPException("could not resolve hostname \"" + host + "\" and no proxy configured");
}
}
/** 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();
+ org.xwt.js.JSArray args = new org.xwt.js.JSArray();
args.addElement(url.toString());
args.addElement(url.getHost());
Object obj = pacFunc.call(args);
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.proxyAutoConfigFunction != null) sock = attemptPAC(pi.proxyAutoConfigFunction);
+ if (sock == null && pi.proxyAutoConfigJSFunction != null) sock = attemptPAC(pi.proxyAutoConfigJSFunction);
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);
if (i+3<type2.length) log += Integer.toString(type2[i+3] & 0xff, 16) + " ";
Log.log(this, log);
}
- // FIXME: need to keep the connection open between type1 and type3
- // FIXME: finish this
+ // FEATURE: need to keep the connection open between type1 and type3
+ // FEATURE: finish this
//byte[] type3 = Proxy.NTLM.getResponse(
//Proxy.Authorization.authorization2 = "NTLM " + Base64.encode(type3));
}
// HTTPInputStream ///////////////////////////////////////////////////////////////////////////////////
/** An input stream that represents a subset of a longer input stream. Supports HTTP chunking as well */
- public class HTTPInputStream extends FilterInputStream {
+ public class HTTPInputStream extends FilterInputStream implements KnownLength {
/** if chunking, the number of bytes remaining in this subset; otherwise the remainder of the chunk */
private int length = 0;
this.length = length == -1 ? 0 : length;
}
+ public int getLength() { return contentLength; }
public boolean markSupported() { return false; }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
public long skip(long n) throws IOException { return read(null, -1, (int)n); }
public String[] excluded = null;
/** the PAC script */
- public JS.Callable proxyAutoConfigFunction = null;
+ public JSCallable proxyAutoConfigJSFunction = null;
public static Proxy detectProxyViaManual() {
Proxy ret = new Proxy();
return ret;
}
- public static JS.Scope proxyAutoConfigRootScope = new ProxyAutoConfigRootScope();
- public static JS.Callable getProxyAutoConfigFunction(String url) {
+ public static JSScope proxyAutoConfigRootJSScope = new ProxyAutoConfigRootJSScope();
+ public static JSCallable getProxyAutoConfigJSFunction(String url) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new HTTP(url, true).GET()));
String s = null;
if (Log.on) Log.log(Proxy.class, script);
}
- JS.CompiledFunction scr = JS.parse("PAC script at " + url, 0, new StringReader(script));
- scr.call(new JS.Array(), proxyAutoConfigRootScope);
- return (JS.Callable)proxyAutoConfigRootScope.get("FindProxyForURL");
+ JSFunction scr = JS.parse("PAC script at " + url, 0, new StringReader(script));
+ scr.cloneWithNewJSScope(proxyAutoConfigRootJSScope).call(new JSArray());
+ return (JSCallable)proxyAutoConfigRootJSScope.get("FindProxyForURL");
} catch (Exception e) {
if (Log.on) {
Log.log(Platform.class, "WPAD detection failed due to:");
if (e instanceof JS.Exn) {
try {
- org.xwt.js.JS.Array arr = new org.xwt.js.JS.Array();
+ org.xwt.js.JSArray arr = new org.xwt.js.JSArray();
arr.addElement(((JS.Exn)e).getObject());
} catch (Exception e2) {
Log.log(Platform.class, e);
if (authorization != oldAuth) return;
if (Log.on) Log.log(Authorization.class, "displaying proxy authorization dialog");
+ /*
Message.Q.add(new Message() {
public void perform() {
Box b = new Box();
b.put("proxyIP", proxyIP);
}
});
-
+ */
waitingForUser.block();
if (Log.on) Log.log(Authorization.class, "got proxy authorization info; re-attempting connection");
}
- // ProxyAutoConfigRootScope ////////////////////////////////////////////////////////////////////
+ // ProxyAutoConfigRootJSScope ////////////////////////////////////////////////////////////////////
- public static class ProxyAutoConfigRootScope extends JS.GlobalScope {
+ public static class ProxyAutoConfigRootJSScope extends JSScope.Global {
- public ProxyAutoConfigRootScope() { super(null); }
+ public ProxyAutoConfigRootJSScope() { super(null); }
public Object get(Object name) {
if (name.equals("isPlainHostName")) return isPlainHostName;
else return super.get(name);
}
- private static final JS.Obj proxyConfigBindings = new JS.Obj();
- private static final JS.Obj ProxyConfig = new JS.Obj() {
+ private static final JSObj proxyConfigBindings = new JSObj();
+ private static final JSObj ProxyConfig = new JSObj() {
public Object get(Object name) {
if (name.equals("bindings")) return proxyConfigBindings;
return null;
}
};
- private static final JS.Callable isPlainHostName = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable isPlainHostName = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
return (args.elementAt(0).toString().indexOf('.') == -1) ? Boolean.TRUE : Boolean.FALSE;
}
};
- private static final JS.Callable dnsDomainIs = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable dnsDomainIs = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
return (args.elementAt(0).toString().endsWith(args.elementAt(1).toString())) ? Boolean.TRUE : Boolean.FALSE;
}
};
- private static final JS.Callable localHostOrDomainIs = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable localHostOrDomainIs = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
return (args.elementAt(0).toString().equals(args.elementAt(1).toString()) ||
(args.elementAt(0).toString().indexOf('.') == -1 && args.elementAt(1).toString().startsWith(args.elementAt(0).toString()))) ?
Boolean.TRUE : Boolean.FALSE;
}
};
- private static final JS.Callable isResolvable = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable isResolvable = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
try {
return (InetAddress.getByName(args.elementAt(0).toString()) != null) ? Boolean.TRUE : Boolean.FALSE;
} catch (UnknownHostException e) {
}
};
- private static final JS.Callable isInNet = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable isInNet = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
if (args.length() != 3) return Boolean.FALSE;
try {
byte[] host = InetAddress.getByName(args.elementAt(0).toString()).getAddress();
}
};
- private static final JS.Callable dnsResolve = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable dnsResolve = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
try {
return InetAddress.getByName(args.elementAt(0).toString()).getHostAddress();
} catch (UnknownHostException e) {
}
};
- private static final JS.Callable myIpAddress = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable myIpAddress = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
}
};
- private static final JS.Callable dnsDomainLevels = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable dnsDomainLevels = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
String s = args.elementAt(0).toString();
int i = 0;
while((i = s.indexOf('.', i)) != -1) i++;
return false;
}
- private static final JS.Callable shExpMatch = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable shExpMatch = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
StringTokenizer st = new StringTokenizer(args.elementAt(1).toString(), "*", false);
String[] arr = new String[st.countTokens()];
String s = args.elementAt(0).toString();
public static String[] days = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
- private static final JS.Callable weekdayRange = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable weekdayRange = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
TimeZone tz = (args.length() < 3 || args.elementAt(2) == null || !args.elementAt(2).equals("GMT")) ? TimeZone.getTimeZone("UTC") : TimeZone.getDefault();
Calendar c = new GregorianCalendar();
c.setTimeZone(tz);
}
};
- private static final JS.Callable dateRange = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable dateRange = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
throw new JS.Exn("XWT does not support dateRange() in PAC scripts");
}
};
- private static final JS.Callable timeRange = new JS.Callable() {
- public Object call(org.xwt.js.JS.Array args) throws JS.Exn {
+ private static final JSCallable timeRange = new JSCallable() {
+ public Object call(org.xwt.js.JSArray args) throws JS.Exn {
throw new JS.Exn("XWT does not support timeRange() in PAC scripts");
}
};
System.arraycopy(highHash, 0, lmHash, 8, 8);
return lmHash;
*/
- return null; // FIXME
+ return null;
}
/**
System.arraycopy(highResponse, 0, lmResponse, 16, 8);
return lmResponse;
*/
- return null; // FIXME
+ return null;
}
/**