Author: bargull
Date: 2007-11-01 06:39:52 -0700 (Thu, 01 Nov 2007)
New Revision: 7077

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js
Log:
Change 20071020-bargull-2 by [EMAIL PROTECTED] on 2007-10-20 17:11:11
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Two improvements for LzHTTPLoader.js

New Features:

Bugs Fixed:
LPP-4945 - Improvements for "LzHTTPLoader.prototype.loadXMLDoc"


Technical Reviewer: hminsky
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
Timeout checking was not removed for erroneous requests in non-proxied DHTML 
applications, this is now fixed.
To test this, you need to uncomment the Debug.write statements in 
LzHTTPLoader.prototype.removeTimeout and LzHTTPLoader.__LZcheckXMLHTTPTimeouts. 
You can see, that erroneous requests were still checked against timeouts.
Additionally, the try..catch block in "LzHTTPLoader.prototype.loadXMLDoc" has 
been shortened, because it was catching just too much errors. Sounds strange, 
but the block was solely added to catch possible errors in Firefox when you 
read out XMLHttpRequest.status on a aborted request and just for this error!



Tests:



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js       
2007-11-01 02:56:13 UTC (rev 7076)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js       
2007-11-01 13:39:52 UTC (rev 7077)
@@ -301,50 +301,54 @@
                 } else if (__pthis__.__abort) {
                     //Debug.write("abort for id=%s, xhr=%w", 
__pthis__.__loaderid, __pthis__.req);
                 } else {
+                    var status = -1;
                     try {
-                        // only if "OK"
-                        //Debug.write("status=%d", __pthis__.req.status);
-                        if (__pthis__.req.status == 200 || 
__pthis__.req.status == 304) {
-                            var elt = null;
-                            var xml = __pthis__.req.responseXML;
-                            __pthis__.responseXML = xml;
-                            var lzxdata = null;
-                            if (xml != null && parsexml) {
-                                var nodes = 
__pthis__.req.responseXML.childNodes;
-                                // find first content (type == 1) child node
-                                for (var i = 0; i < nodes.length; i++) {
-                                    var child = nodes.item(i);
-                                    if (child.nodeType == 1) {
-                                        elt = child;
-                                        break;
-                                    }
+                        status = __pthis__.req.status;
+                    } catch (e) {
+                        //if you abort a request, readyState will be set to 4, 
+                        //but reading status will result in an exception (at 
least in Firefox).
+                        //Debug.write("catched error: %s", e);
+                    }
+                    
+                    // only if "OK"
+                    //Debug.write("status=%d", status);
+                    if (status == 200 || status == 304) {
+                        var elt = null;
+                        var xml = __pthis__.req.responseXML;
+                        __pthis__.responseXML = xml;
+                        var lzxdata = null;
+                        if (xml != null && parsexml) {
+                            var nodes = __pthis__.req.responseXML.childNodes;
+                            // find first content (type == 1) child node
+                            for (var i = 0; i < nodes.length; i++) {
+                                var child = nodes.item(i);
+                                if (child.nodeType == 1) {
+                                    elt = child;
+                                    break;
                                 }
-                                lzxdata = LzXMLTranslator.copyXML(elt,
-                                                            
__pthis__.options.trimwhitespace,
-                                                            
__pthis__.options.nsprefix);
                             }
+                            lzxdata = LzXMLTranslator.copyXML(elt,
+                                                        
__pthis__.options.trimwhitespace,
+                                                        
__pthis__.options.nsprefix);
+                        }
                     
-                            __pthis__.responseText = 
__pthis__.req.responseText;
-                            __pthis__.removeTimeout(__pthis__);
+                        __pthis__.responseText = __pthis__.req.responseText;
+                        __pthis__.removeTimeout(__pthis__);
                     
                     
                     
-                            /**** DEBUGGING 
-                            var xmlSerializer = new XMLSerializer();
-                            var markup = xmlSerializer.serializeToString(elt);
-                            Debug.write("loadXMLDoc", elt, markup, 
d.serialize());
-                             *** /DEBUGGING
-                             */
-                            __pthis__.req = null;
-                            __pthis__.loadSuccess(__pthis__, lzxdata);
-                        } else {
-                            __pthis__.req = null;
-                            __pthis__.loadError(__pthis__, null);
-                        }
-                    } catch (e) {
-                        //if you abort a request, readyState will be set to 4, 
-                        //but reading status will result in an exception (at 
least in Firefox).
-                        //Debug.write("catched error: %s", e);
+                        /**** DEBUGGING 
+                        var xmlSerializer = new XMLSerializer();
+                        var markup = xmlSerializer.serializeToString(elt);
+                        Debug.write("loadXMLDoc", elt, markup, d.serialize());
+                         *** /DEBUGGING
+                         */
+                        __pthis__.req = null;
+                        __pthis__.loadSuccess(__pthis__, lzxdata);
+                    } else {
+                        __pthis__.removeTimeout(__pthis__);
+                        __pthis__.req = null;
+                        __pthis__.loadError(__pthis__, null);
                     }
                 }
             }


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

Reply via email to