2002/05/05 08:37:32
[org.ibex.core.git] / src / org / xwt / XMLRPC.java
index 3201ecd..274b5ef 100644 (file)
@@ -230,14 +230,21 @@ class XMLRPC extends XML implements Function {
         }
     }
 
-    private Object connect(Object[] args) throws JavaScriptException, IOException {
+    public Object call(Object[] args) throws JavaScriptException, IOException {
         if (Log.verbose) Log.log(this, "call to " + url + " : " + methodname);
+
+        if (tracker == null) tracker = new Hash();
+        else tracker.clear();
+
+        if (objects == null) objects = new Vec();
+        else objects.setSize(0);
+
         HTTP http = new HTTP(url);
         String content = send(args, http);
         OutputStream os = new BufferedOutputStream(http.getOutputStream(content.length(), "text/xml"), 4000);
         PrintWriter ps = !Log.verbose ?
             new PrintWriter(os) :
-            new PrintWriter(new FilterWriter(os)) {
+            new PrintWriter(new FilterWriter(new OutputStreamWriter(os)) {
                     public void write(int i) throws IOException {
                         super.write(i);
                         if (Log.on) Log.log(this, "send: " + ((char)i));
@@ -274,7 +281,7 @@ class XMLRPC extends XML implements Function {
         return recieve(br);
     }
 
-    protected String send(Object[] args, HTTP http) throws JavaScriptException {
+    protected String send(Object[] args, HTTP http) throws JavaScriptException, IOException {
         StringBuffer content = new StringBuffer();
         content.append("<?xml version=\"1.0\"?>\n");
         content.append("    <methodCall>\n");
@@ -310,12 +317,6 @@ class XMLRPC extends XML implements Function {
 
     public final Object call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args) throws JavaScriptException {
 
-        if (tracker == null) tracker = new Hash();
-        else tracker.clear();
-
-        if (objects == null) objects = new Vec();
-        else objects.setSize(0);
-
         // put ourselves in the background
         Thread thread = Thread.currentThread();
         if (!(thread instanceof ThreadMessage)) {
@@ -327,7 +328,7 @@ class XMLRPC extends XML implements Function {
         mythread.done.release();
 
         try {
-            return connect(args);
+            return call(args);
 
         } catch (IOException se) {
             if (Log.on) Log.log(this, se);