[Laszlo-checkins] r10211 - in openlaszlo/trunk: WEB-INF/lps/lfc/data WEB-INF/lps/lfc/kernel/swf test/lfc/data

hqm@openlaszlo.org hqm at openlaszlo.org
Thu Jul 3 16:53:32 PDT 2008


Author: hqm
Date: 2008-07-03 16:53:23 -0700 (Thu, 03 Jul 2008)
New Revision: 10211

Added:
   openlaszlo/trunk/test/lfc/data/echobody.jsp
Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
   openlaszlo/trunk/test/lfc/data/alldata.lzx
   openlaszlo/trunk/test/lfc/data/testgetmethod.lzx
   openlaszlo/trunk/test/lfc/data/testgetmethodsolo.lzx
   openlaszlo/trunk/test/lfc/data/testpostmethod.lzx
   openlaszlo/trunk/test/lfc/data/testpostmethodsolo.lzx
   openlaszlo/trunk/test/lfc/data/testsetheaders-solo.lzx
Log:
Change 20080703-hqm-j by hqm at badtzmaru.home on 2008-07-03 13:15:44 EDT
    in /Users/hqm/openlaszlo/trunk4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: fix for SOLO POST bug

New Features:

Bugs Fixed: LPP-6586 

Technical Reviewer: max
QA Reviewer: pbr
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    
+ The code in LZHTTPDataProvider was sending all POST data through
LZHTTPLoader API, but SWF8 cannot really post raw data in SOLO mode,
it treats it like XML and will escape '&' and '<' chars.

Fix is to add a flag, "hasquerydata", that is set as an option of the LzHTTPLoader,
to give it a hint as to how to POST the data. If it is query data, send it using the 
Flash LoadVars.sendAndLoad API. If it is "raw", send it using the XML.sendAndLoad (which
is better than nothing).

+ fixed regression test to more carefully look at echoed data from server

+ fixed regression where SWF media loads are always proxied, regardless of canvas.proxied setting

Tests:

test/lfc/data/alldata.lzx (swf, dhtml)
calendar (solo,proxied)
amazon (solo swf,proxied)

+ use "net" debug tab in Firebug to make sure SOLO image loads are not proxied via server




Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-07-03 23:53:23 UTC (rev 10211)
@@ -742,8 +742,9 @@
     // the DataRequest.postbody field to the lzpostbody value.
     // 
     if (this.querytype.toUpperCase() == "POST") {
-        var lzpostbody = null;
+        var lzpostbody = this.postbody;
         if (dreq.queryparams) {
+            // a "lzpostbody" arg overrides postbody, for back compatibility
             lzpostbody = dreq.queryparams.getValue('lzpostbody');
         }
         // If there is a lzpostbody query arg, we are going to remove
@@ -757,7 +758,9 @@
         // 
         if (lzpostbody != null) { 
             dreq.postbody = lzpostbody;
-            dreq.queryparams.remove('lzpostbody');
+            if (dreq.queryparams && dreq.queryparams['lzpostbody']) {
+                dreq.queryparams.remove('lzpostbody');
+            }
         }
     }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs	2008-07-03 23:53:23 UTC (rev 10211)
@@ -148,6 +148,10 @@
 
         var cachebreak = "__lzbc__="+(new Date()).getTime();
 
+        // Default assume we are posting query data (key-value pairs)
+        var hasquerydata = true;
+
+
         var postbody = dreq.postbody;
         if (postbody == null && qparams != null) {
             var names = qparams.getNames();
@@ -158,8 +162,14 @@
             }
 
             postbody = q;
+        } else {
+            //We are asking the swf8 runtime to treat this as raw data, as best it can
+            hasquerydata = false;
         }
 
+        tloader.setOption('hasquerydata', hasquerydata);
+
+
         var lzurl = new LzURL(dreq.src);
 
         // For GET requests, merge in params data with URL query 
@@ -337,7 +347,6 @@
     var postbody:String;
     var proxied:Boolean;
     var proxyurl:String;  
-
     var multirequest:Boolean = false;
     var queuerequests:Boolean = false;
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as	2008-07-03 23:53:23 UTC (rev 10211)
@@ -132,6 +132,7 @@
     var xmlrequestobj = new XML();
     
     xmlrequestobj.cache = this.options.cacheable;
+    xmlrequestobj.hasquerydata = this.options.hasquerydata;
 
     if (typeof(lzloader.timeout) != 'undefined') {
         xmlrequestobj.timeout = lzloader.timeout;

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as	2008-07-03 23:53:23 UTC (rev 10211)
@@ -418,8 +418,6 @@
 }
 
 
-
-
 /**
   * @access private
   */
@@ -493,7 +491,6 @@
             lvar[key] = pdata[key];
         }
 
-
         lvar.sendAndLoad(reqstr , loadobj, "POST" );
     } else {
         // SOLO request:
@@ -507,7 +504,13 @@
                 lvar.addRequestHeader(header, headers[header]);
             }
             var lzpostbody = loadobj.rawpostbody;
-            if (lzpostbody != null) {
+            var hasquerydata = loadobj.hasquerydata; // boolean
+            if (lzpostbody != null && !hasquerydata) {
+                // This is supposed to be a "raw" data post. The best
+                // we can do is to use XML.sendAndLoad, with a Flash
+                // XML Text node as the data. This will still
+                // XML-escape it, but it's as close as we can get to POSTing
+                // raw data.
                 var xmlraw = new XML();
                 var tnode = xmlraw.createTextNode(lzpostbody);
                 xmlraw.appendChild(tnode);
@@ -516,6 +519,12 @@
                 }
                 xmlraw.sendAndLoad(reqstr, loadobj);
             } else {
+                var content = loadobj.rawpostbody;
+                // Copy the postbody data onto the LoadVars, it will be POST'ed
+                var pdata = LzParam.parseQueryString(content);
+                for ( var key in pdata) {
+                    lvar[key] = pdata[key];
+                }
                 lvar.sendAndLoad(reqstr , loadobj , "POST");
             }
         } else {

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs	2008-07-03 23:53:23 UTC (rev 10211)
@@ -328,7 +328,11 @@
     }
 
     lmv.lzt = o.lzt;
-    o.proxyurl = canvas.getProxyURL(o.url);
+    if (o.proxied) {
+        o.proxyurl = canvas.getProxyURL(o.url);
+    } else {
+        o.proxyurl = null;
+    }
 
     if (typeof(o.proxied) != undefined && o.proxied != null) {
         lmv.proxied = o.proxied;
@@ -357,6 +361,7 @@
         LzLoader.debugLoadObj(o);
     }
     this.initializeRequestObj(o);
+
     LzLoadQueue.enqueueRequest( o );
     // We should probably be passing something other than the obj itself to
     // the onrequest event

Modified: openlaszlo/trunk/test/lfc/data/alldata.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/alldata.lzx	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/test/lfc/data/alldata.lzx	2008-07-03 23:53:23 UTC (rev 10211)
@@ -26,8 +26,8 @@
     <include href="testput.lzx"/>
 <!--     <include href="testrawpost-solo.lzx"/> -->
     <include href="testheaderresponse.lzx"/>
-    <include href="testclientcachebreaker.lzx"/>
     <include href="sendheaders.lzx"/>
+    <include href="testclientcachebreaker.lzx"/>
 
     <TestSuite>
         <TestDatanode/>
@@ -58,7 +58,6 @@
 
         <TestClientCacheBreaker/>
 
-
     </TestSuite>
 </canvas>
 <!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************

Added: openlaszlo/trunk/test/lfc/data/echobody.jsp


Property changes on: openlaszlo/trunk/test/lfc/data/echobody.jsp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: openlaszlo/trunk/test/lfc/data/testgetmethod.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/testgetmethod.lzx	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/test/lfc/data/testgetmethod.lzx	2008-07-03 23:53:23 UTC (rev 10211)
@@ -47,9 +47,10 @@
 
         <method name="doIt" args="dp">
             <![CDATA[
-                     var resp = dp.xpathQuery( '/echo/data/text()');
-                     assertTrue( resp.indexOf("617-987-1234") > 0);
-                     assertTrue( resp.indexOf("67 Clyde Street") > 0);
+                     var phone = dp.xpathQuery( '/echo/phone/text()');
+                     assertEquals( "617-987-1234", phone );
+                     var addr = dp.xpathQuery( '/echo/address/text()');
+                     assertEquals( "67 Clyde Street", addr);
             ]]>
         </method>
     </class>

Modified: openlaszlo/trunk/test/lfc/data/testgetmethodsolo.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/testgetmethodsolo.lzx	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/test/lfc/data/testgetmethodsolo.lzx	2008-07-03 23:53:23 UTC (rev 10211)
@@ -1,7 +1,7 @@
 <library>
   <include href="lzunit/lzunit.lzx" />
 
-  <dataset name="dsgetsolo_" src="http:echo.jsp" 
+  <dataset name="dsgetsolo_" src="http:echobody.jsp" 
            getresponseheaders="true"  proxied="false"
            timeout="120000"/>
 
@@ -47,9 +47,13 @@
 
         <method name="doIt" args="dp">
             <![CDATA[
-                     var resp = dp.xpathQuery( '/echo/data/text()');
-                     assertTrue( resp.indexOf("617-987-1234") > 0);
-                     assertTrue( resp.indexOf("67 Clyde Street") > 0);
+                     var phone = dp.xpathQuery( '/echo/phone/text()');
+                     assertEquals( "617-987-1234", phone );
+                     var addr = dp.xpathQuery( '/echo/address/text()');
+                     assertEquals( "67 Clyde Street", addr);
+                     var method = dp.xpathQuery( '/echo/method/@type');
+                     assertEquals( "GET", method);
+
             ]]>
         </method>
     </class>

Modified: openlaszlo/trunk/test/lfc/data/testpostmethod.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/testpostmethod.lzx	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/test/lfc/data/testpostmethod.lzx	2008-07-03 23:53:23 UTC (rev 10211)
@@ -1,7 +1,7 @@
 <library>
   <include href="lzunit/lzunit.lzx" />
 
-  <dataset name="dsget_post_prox" src="http:echo.jsp" 
+  <dataset name="dsget_post_prox" src="http:echobody.jsp" 
            getresponseheaders="true"  proxied="false"
            timeout="120000"/>
 
@@ -21,7 +21,7 @@
     <method name="sendit">
       dsget_post_prox.setQueryParam("address", "67 Clyde Street");
       dsget_post_prox.setQueryParam("phone", "617-987-1234");
-      dsget_post_prox.setQueryType("GET");
+      dsget_post_prox.setQueryType("POST");
       dsget_post_prox.doRequest();
     </method>
 
@@ -47,9 +47,13 @@
 
         <method name="doIt" args="dp">
             <![CDATA[
-                     var resp = dp.xpathQuery( '/echo/data/text()');
-                     assertTrue( resp.indexOf("617-987-1234") > 0);
-                     assertTrue( resp.indexOf("67 Clyde Street") > 0);
+                     var phone = dp.xpathQuery( '/echo/phone/text()');
+                     assertEquals( "617-987-1234", phone );
+                     var addr = dp.xpathQuery( '/echo/address/text()');
+                     assertEquals( "67 Clyde Street", addr);
+
+                     var method = dp.xpathQuery( '/echo/method/@type');
+                     assertEquals( "POST", method);
             ]]>
         </method>
     </class>

Modified: openlaszlo/trunk/test/lfc/data/testpostmethodsolo.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/testpostmethodsolo.lzx	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/test/lfc/data/testpostmethodsolo.lzx	2008-07-03 23:53:23 UTC (rev 10211)
@@ -1,7 +1,7 @@
 <library>
   <include href="lzunit/lzunit.lzx" />
 
-  <dataset name="dsget_post_solo" src="http:echo.jsp" 
+  <dataset name="dsget_post_solo" src="http:echobody.jsp" 
            getresponseheaders="true"  proxied="false"
            timeout="120000"/>
 
@@ -21,7 +21,7 @@
     <method name="sendit">
       dsget_post_solo.setQueryParam("address", "67 Clyde Street");
       dsget_post_solo.setQueryParam("phone", "617-987-1234");
-      dsget_post_solo.setQueryType("GET");
+      dsget_post_solo.setQueryType("POST");
       dsget_post_solo.doRequest();
     </method>
 
@@ -47,9 +47,12 @@
 
         <method name="doIt" args="dp">
             <![CDATA[
-                     var resp = dp.xpathQuery( '/echo/data/text()');
-                     assertTrue( resp.indexOf("617-987-1234") > 0);
-                     assertTrue( resp.indexOf("67 Clyde Street") > 0);
+                     var phone = dp.xpathQuery( '/echo/phone/text()');
+                     assertEquals( "617-987-1234", phone );
+                     var addr = dp.xpathQuery( '/echo/address/text()');
+                     assertEquals( "67 Clyde Street", addr);
+                     var method = dp.xpathQuery( '/echo/method/@type');
+                     assertEquals( "POST", method);
             ]]>
         </method>
     </class>

Modified: openlaszlo/trunk/test/lfc/data/testsetheaders-solo.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/testsetheaders-solo.lzx	2008-07-03 23:41:17 UTC (rev 10210)
+++ openlaszlo/trunk/test/lfc/data/testsetheaders-solo.lzx	2008-07-03 23:53:23 UTC (rev 10211)
@@ -20,11 +20,12 @@
 
     <method name="sendit">
       Debug.write("testsetheaders.lzx sending edata_solo");
+      edata_solo.setQueryParam("flash", "has some bugs");
+      edata_solo.setQueryType("POST");
+
       edata_solo.setHeader("content-type", "pink-elephants/xml");
       edata_solo.setHeader("my-personal-header", "vanilla/with-chocolate-syrup");
       edata_solo.setHeader("my-other-personal-header", "milk chocolate with almonds");
-      edata_solo.setQueryParam("flash", "has some bugs");
-      edata_solo.setQueryType("POST");
       edata_solo.doRequest();
     </method>
 



More information about the Laszlo-checkins mailing list