[OpenSRF-GIT] OpenSRF branch master updated. 5a21d6356efa0176cf32d097777979154c1dd2ee

Evergreen Git git at git.evergreen-ils.org
Fri May 25 23:09:04 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, master has been updated
       via  5a21d6356efa0176cf32d097777979154c1dd2ee (commit)
      from  bb5018f1bf16fd9bb9e61b43286dbf0a6257bf5b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5a21d6356efa0176cf32d097777979154c1dd2ee
Author: Bill Erickson <berick at esilibrary.com>
Date:   Mon Apr 2 14:55:56 2012 -0400

    Detect and repair multipart/mixed message delivery errors
    
    For unknown reasons, the Content-Type header will occasionally be
    included in the XHR.responseText for multipart/mixed messages.  When
    this happens, strip the header and newlines from the message body and
    re-parse.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Dan Scott <dan at coffeecode.net>

diff --git a/src/javascript/opensrf.js b/src/javascript/opensrf.js
index dfff52a..c0e454c 100644
--- a/src/javascript/opensrf.js
+++ b/src/javascript/opensrf.js
@@ -388,11 +388,43 @@ OpenSRF.Stack = function() {
 // global inbound message queue
 OpenSRF.Stack.queue = [];
 
+// XXX testing
+function log(msg) {
+    try {
+        dump(msg + '\n'); // xulrunner
+    } catch(E) {
+        console.log(msg);
+    }
+}
+
 OpenSRF.Stack.push = function(net_msg, callbacks) {
     var ses = OpenSRF.Session.find_session(net_msg.thread); 
     if(!ses) return;
     ses.remote_id = net_msg.from;
-    osrf_msgs = JSON2js(net_msg.body);
+    osrf_msgs = [];
+
+    try {
+        osrf_msgs = JSON2js(net_msg.body);
+
+    } catch(E) {
+        log('Error parsing OpenSRF message body as JSON: ' + net_msg.body + '\n' + E);
+
+        /** UGH
+          * For unknown reasons, the Content-Type header will occasionally
+          * be included in the XHR.responseText for multipart/mixed messages.
+          * When this happens, strip the header and newlines from the message
+          * body and re-parse.
+          */
+        net_msg.body = net_msg.body.replace(/^.*\n\n/, '');
+        log('Cleaning up and retrying...');
+
+        try {
+            osrf_msgs = JSON2js(net_msg.body);
+        } catch(E2) {
+            log('Unable to clean up message, giving up: ' + net_msg.body);
+            return;
+        }
+    }
 
     // push the latest responses onto the end of the inbound message queue
     for(var i = 0; i < osrf_msgs.length; i++)

-----------------------------------------------------------------------

Summary of changes:
 src/javascript/opensrf.js |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list