[Pkg-javascript-commits] [sockjs-client] 117/434: chunking detection needs to be within the loop. Maybe the whole loop should be made as a recursion some day.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:08 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 5e4ce6d6bfc54c689b7cee67387cb35e3f0de4e5
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Mon Sep 5 16:40:00 2011 +0100

    chunking detection needs to be within the loop. Maybe the whole loop should be made as a recursion some day.
---
 lib/sockjs.js | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/lib/sockjs.js b/lib/sockjs.js
index dca1950..a35b3fb 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -136,31 +136,33 @@ SockJS.prototype._try_next_protocol = function(close_event) {
         that.protocol = null;
     }
 
-    // Some protocols require chunking, we may need to run the test beforehand.
-    var protocol = that._protocols[0];
-    if (protocol && SockJS[protocol] &&
-          SockJS[protocol].need_chunking === true &&
-          that._options.chunking === undefined) {
-        chunkingTest(that._base_url, function(chunking) {
-                         that._options.chunking = chunking;
-                         that._try_next_protocol();
-                     });
-        return true;
-    }
-
     while(1) {
-        that.protocol = that._protocols.shift();
-        if (!that.protocol) {
+        var protocol = that.protocol = that._protocols.shift();
+        if (!protocol) {
             return false;
         }
-        if (!SockJS[that.protocol] ||
-              (SockJS[that.protocol].need_chunking === true &&
+        // Some protocols require chunking, we may need to run the
+        // test beforehand.
+        if (SockJS[protocol] &&
+              SockJS[protocol].need_chunking === true &&
+              that._options.chunking === undefined) {
+            that._protocols.unshift(protocol);
+            that.protocol = 'chunking-test';
+            chunkingTest(that._base_url, function(chunking) {
+                             that._options.chunking = chunking;
+                             that._try_next_protocol();
+                         });
+            return true;
+        }
+
+        if (!SockJS[protocol] ||
+              (SockJS[protocol].need_chunking === true &&
                    that._options.chunking !== true) ||
-              !SockJS[that.protocol].enabled(that._options)) {
-            that._debug('Skipping transport:', that.protocol);
+              !SockJS[protocol].enabled(that._options)) {
+            that._debug('Skipping transport:', protocol);
         } else {
-            that._debug('Opening transport:', that.protocol);
-            that._transport = new SockJS[that.protocol](that, that._trans_url,
+            that._debug('Opening transport:', protocol);
+            that._transport = new SockJS[protocol](that, that._trans_url,
                                                         that._base_url);
             return true;
         }

-- 
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