You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2011/06/09 10:44:25 UTC

svn commit: r1133723 - /shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js

Author: lindner
Date: Thu Jun  9 08:44:24 2011
New Revision: 1133723

URL: http://svn.apache.org/viewvc?rev=1133723&view=rev
Log:
Patch from mhermanto: Allow a container to disable gadgets.rpc forcesecure in wpm.

Motivation here is to allow existing clients (who may misuse
gadgets.rpc) to continue to work.

Modified:
    shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js

Modified: shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js?rev=1133723&r1=1133722&r2=1133723&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js (original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js Thu Jun  9 08:44:24 2011
@@ -45,6 +45,7 @@ if (!gadgets.rpctx.wpm) {  // make lib r
 
   gadgets.rpctx.wpm = function() {
     var process, ready;
+    var forceSecure = true;
 
     function attachBrowserEvent(eventName, callback, useCapture) {
       if (typeof window.addEventListener != 'undefined') {
@@ -76,8 +77,9 @@ if (!gadgets.rpctx.wpm) {  // make lib r
       // event.origin does not exist, use event.domain.  The other difference is that
       // while event.origin looks like <scheme>://<hostname>:<port>, event.domain
       // consists only of <hostname>.
-      if (typeof packet.origin !== 'undefined' ? packet.origin !== origin :
-          packet.domain !== /^.+:\/\/([^:]+).*/.exec(origin)[1]) {
+      if (forceSecure && (typeof packet.origin !== "undefined"
+          ? packet.origin !== origin
+          : packet.domain !== /^.+:\/\/([^:]+).*/.exec(origin)[1])) {
         return;
       }
       process(rpc, packet.origin);
@@ -93,6 +95,14 @@ if (!gadgets.rpctx.wpm) {  // make lib r
       },
 
       init: function(processFn, readyFn) {
+        function configure(config) {
+          var cfg = config ? config['rpc'] : {};
+          if (String(cfg['disableForceSecure']) === 'true') {
+            forceSecure = false;
+          }
+        }
+        gadgets.config.register('rpc', null, configure);
+
         process = processFn;
         ready = readyFn;