Revision: 3139
          http://vexi.svn.sourceforge.net/vexi/?rev=3139&view=rev
Author:   mkpg2
Date:     2008-10-25 04:16:14 +0000 (Sat, 25 Oct 2008)

Log Message:
-----------
Fix/Hack. Recreate internal http object with xmlrpc requests to ensure that 
they can be reused.

The correct fix would be to make the http accept consecutive requests, i.e. 
fixing the piplining.

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp
    trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java
    trunk/core/org.ibex.net/src/org/ibex/net/HTTP.jpp

Modified: trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp   2008-10-21 13:36:06 UTC 
(rev 3138)
+++ trunk/core/org.ibex.js/src/org/ibex/js/XMLRPC.jpp   2008-10-25 04:16:14 UTC 
(rev 3139)
@@ -39,7 +39,7 @@
 public class XMLRPC extends JS.Immutable implements Constants {
 
     public XMLRPC(String url, String method) {
-        this.http = url.startsWith("stdio:") ? HTTP.stdio : new HTTP(url);
+        this.http[0] = url.startsWith("stdio:") ? HTTP.stdio : new HTTP(url);
         this.url = url;
         this.method = method;
     }
@@ -57,7 +57,10 @@
     };
     protected String url = null;         ///< the url to connect to
     protected String method = null;      ///< the method name to invoke on the 
remove server
-    protected HTTP http = null;          ///< the HTTP connection to use
+    
+    // HACK - ideally we should fix the http object and allow it to be reused (
+    // as this should enable piping)
+    protected HTTP[] http = new HTTP[2];          ///< the HTTP connection to 
use
     private Basket.Map tracker;          ///< used to detect multi-ref data
     protected boolean fault = false;     ///< True iff the return value is a 
fault (and should be thrown as an exception)
 
@@ -335,7 +338,9 @@
             throw new JSExn("cannot invoke an XML-RPC call in the foreground 
thread");
         }
     }
+    
 
+    
     final Object doCall(final JSArray args) {
        try{
             if (Log.rpc) Log.uInfo(LOG_TYPE, "call to " + url + " : " + 
method);
@@ -343,7 +348,11 @@
             if (objects == null) objects = new Basket.Array();
             String request = buildRequest(args);
                if (Log.rpc) Log.uInfo(LOG_TYPE, "send:\n" + request);
-            InputStream is = http.POST("text/xml", request.getBytes("UTF-8"), 
null, null);
+            if(http[1]!=null){
+               http[0] = new HTTP(http[1]);
+            }
+               InputStream is = http[0].POST("text/xml", 
request.getBytes("UTF-8"), null, null);
+               http[1] = http[0];
             InputStreamReader ir = new InputStreamReader(is);
             BufferedReader br = Log.rpc?new LoggingReader(ir):
                                                        new BufferedReader(ir);
@@ -368,8 +377,8 @@
        }catch (final JSExn e) {
                return e; 
         } catch (final Throwable e) {
-               if(e instanceof Error) Log.error(XMLRPC.class, e);
-               else Log.info(XMLRPC.class, e);
+               if(e instanceof IOException) Log.info(XMLRPC.class, e);
+               else Log.error(XMLRPC.class, e);
             final String msg = e.getMessage();
             return new JSExn(JSU.S(msg), SC_xmlrpc);
         }

Modified: 
trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java    
2008-10-21 13:36:06 UTC (rev 3138)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java    
2008-10-25 04:16:14 UTC (rev 3139)
@@ -44,7 +44,7 @@
                        Object r = 
xmlrpc.execute("testServer.stringWithEmptyline", params);
                        System.out.println(r);*/
                        
-                       RunJS.runJSFile(new String[]{resourceDir}, 
"emptyline.js");
+                       RunJS.runJSFile(new String[]{resourceDir}, "reuse.js");
                }finally{
                        testwebserver.shutdown();                       
                }

Modified: trunk/core/org.ibex.net/src/org/ibex/net/HTTP.jpp
===================================================================
--- trunk/core/org.ibex.net/src/org/ibex/net/HTTP.jpp   2008-10-21 13:36:06 UTC 
(rev 3138)
+++ trunk/core/org.ibex.net/src/org/ibex/net/HTTP.jpp   2008-10-25 04:16:14 UTC 
(rev 3139)
@@ -102,10 +102,12 @@
     }
 
     // Public Methods 
////////////////////////////////////////////////////////////////////////////////////////
-
     public HTTP(String url) { this(url, false); }
     public HTTP(String url, boolean skipResolveCheck) { originalUrl = url; 
this.skipResolveCheck = skipResolveCheck; }
-
+    // HACK
+    public HTTP(HTTP old) { this(old.originalUrl, old.skipResolveCheck); }
+    
+    
     /** Performs an HTTP GET request */
     public InputStream GET(String referer, Cookie.Jar cookies) throws 
IOException {
         return makeRequest("GET", null, referer, cookies); }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to