Author: hqm
Date: 2008-02-25 12:17:25 -0800 (Mon, 25 Feb 2008)
New Revision: 8100

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
Log:
Change 20080225-hqm-q by [EMAIL PROTECTED] on 2008-02-25 12:53:53 EST
    in /Users/hqm/openlaszlo/trunk/WEB-INF/lps/lfc
    for http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc

Summary: add data to SWF SOLO POST requests, to ensure that Flash does not turn 
them into GET requests

New Features:

Bugs Fixed: LPP-5368

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

Documentation:

Release Notes:

Details:
    
SWF has a bug whereby an empty POST request (one with no data in it's post 
body) is turned into a
 GET request. This behavior used to be masked by the way we forced all query 
args into the POST
body for post requests.

When a change was made to  separate  and preserve the query string from the 
post body, people
started reporting bugs where their POST requests became GET requests.

This patch forces the "__lzbc__" cache-breaking timestamp arg into the body of 
SOLO post requests.

I am wondering if I should also force this value into Proxied requests, to 
ensure that
the data which is sent to the back-end is consistent between SOLO and proxied 
requests. This
patch only forces the __lzbc__ arg into SOLO POST  requests.


Tests:

test.lzx:
<canvas debug="true" height="400" >
    <dataset name="dsGroups" request="true" type="http" src="test.jsp" 
querytype="POST"/>
    <datapointer name="dpGroups" xpath="dsGroups:/Response">
        <handler name="ondata" args="d"><![CDATA[
            Debug.write(d);
        ]]></handler>
    </datapointer>
</canvas>

test.jsp:
<%System.out.println(request.getMethod());%>
<Response>
        <Method><%=request.getMethod()%></Method>
</Response>




Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs        
2008-02-25 19:18:50 UTC (rev 8099)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs        
2008-02-25 20:17:25 UTC (rev 8100)
@@ -132,6 +132,9 @@
         
         // If an explicit post body content arg wasn't supplied, make
         // a url-form-encoded string from the queryparams data.
+
+        var cachebreak = "__lzbc__="+(new Date()).getTime();
+
         var postbody = dreq.postbody;
         if (postbody == null && qparams != null) {
             var names = qparams.getNames();
@@ -140,6 +143,15 @@
                 q += sep + name + '=' + 
encodeURIComponent(qparams.getValue(name));
                 sep = '&';
             }
+
+            // [LPP-5368] If this is a SOLO POST request, put the
+            // 'cache-breaking' arg into this post body. This prevents
+            // the case of an empty POST body, which would cause the
+            // Flash player to turn it into a GET request.
+            if (!proxied && (dreq.method == "POST") &&  !dreq.clientcacheable) 
{
+                q += cachebreak;
+            }
+
             postbody = q;
         }
 
@@ -155,7 +167,6 @@
             postbody = null;
         }
 
-        var cachebreak = "__lzbc__="+(new Date()).getTime();
         // convert url back to string
         url = lzurl.toString();
         var url;
@@ -175,10 +186,16 @@
         }  else {
             // break the browser cache by adding a unique string to the url
             if (!dreq.clientcacheable) {
-                if (lzurl.query == null) {
-                    lzurl.query = cachebreak;
+                if (dreq.method == "POST") {
+                    //POST case:
+                    // cache break arg already added to post body
                 } else {
-                    lzurl.query += ("&" + cachebreak);
+                    // GET case: add to url query portion
+                    if (lzurl.query == null) {
+                        lzurl.query = cachebreak;
+                    } else {
+                        lzurl.query += ("&" + cachebreak);
+                    }
                 }
             }
 


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to