Scriptable thisObj,
final Object[] args,
Function funObj)
throws JavaScriptException {
int len = args.length;
final Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
final ScriptableObject go = ((RhinoInterpreter.ExtendedContext)cx).getGlobalObject();
if (len < 3) {
throw Context.reportRuntimeError("invalid argument count");
}
RhinoInterpreter interp =
(RhinoInterpreter)window.getInterpreter();
final String uri = (String)Context.toType(args[0], String.class);
final String content = (String)Context.toType(args[1], String.class);
Window.URLResponseHandler urlHandler = null;
if (args[2] instanceof Function) {
urlHandler = new GetURLFunctionWrapper
(interp, (Function)args[2], go);
} else {
urlHandler = new GetURLObjectWrapper
(interp, (NativeObject)args[2], go);
}
final Window.URLResponseHandler fw = urlHandler;
AccessControlContext acc;
acc = interp.getAccessControlContext();
switch (len) {
case 3:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run(){
window.postURL(uri, content, fw);
return null;
}
}, acc);
case 4:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
window.postURL
(uri, content, fw,
(String)Context.toType(args[3], String.class));
return null;
}
}, acc);
default:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
window.postURL
(uri, content, fw,
(String)Context.toType(args[3], String.class),
(String)Context.toType(args[4], String.class));
return null;
}