[Pkg-javascript-commits] [sockjs-client] 428/434: Fix #66: failure to post data to /xhr_send should kill the session

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:30 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 5ab87693927fec8c12aaa04cf2493217ba93ab5d
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Mon May 14 15:47:49 2012 +0100

    Fix #66: failure to post data to /xhr_send should kill the session
---
 lib/trans-sender.js | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib/trans-sender.js b/lib/trans-sender.js
index e5d300c..da4639e 100644
--- a/lib/trans-sender.js
+++ b/lib/trans-sender.js
@@ -45,12 +45,14 @@ BufferedSender.prototype.send_schedule = function() {
     var that = this;
     if (that.send_buffer.length > 0) {
         var payload = '[' + that.send_buffer.join(',') + ']';
-        that.send_stop = that.sender(that.trans_url,
-                                     payload,
-                                     function() {
-                                         that.send_stop = null;
-                                         that.send_schedule_wait();
-                                     });
+        that.send_stop = that.sender(that.trans_url, payload, function(success, abort_reason) {
+            that.send_stop = null;
+            if (success === false) {
+                that.ri._didClose(1006, 'Sending error ' + abort_reason);
+            } else {
+                that.send_schedule_wait();
+            }
+        });
         that.send_buffer = [];
     }
 };
@@ -113,7 +115,9 @@ var jsonPGenericSender = function(url, payload, callback) {
                        iframe = null;
                    });
         area.value = '';
-        callback();
+        // It is not possible to detect if the iframe succeeded or
+        // failed to submit our form.
+        callback(true);
     };
     iframe.onerror = iframe.onload = completed;
     iframe.onreadystatechange = function(e) {
@@ -126,10 +130,11 @@ var createAjaxSender = function(AjaxObject) {
     return function(url, payload, callback) {
         var xo = new AjaxObject('POST', url + '/xhr_send', payload);
         xo.onfinish = function(status, text) {
-            callback(status);
+            callback(status === 200 || status === 204,
+                     'http status ' + status);
         };
         return function(abort_reason) {
-            callback(0, abort_reason);
+            callback(false, abort_reason);
         };
     };
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list