Author: zhoresh
Date: Mon Feb  7 23:32:03 2011
New Revision: 1068222

URL: http://svn.apache.org/viewvc?rev=1068222&view=rev
Log:
kage of makeNonProxiedRequest | http://codereview.appspot.com/4029052/ | patch 
by jtarrio

Modified:
    shindig/trunk/features/src/main/javascript/features/core.io/io.js

Modified: shindig/trunk/features/src/main/javascript/features/core.io/io.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.io/io.js?rev=1068222&r1=1068221&r2=1068222&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.io/io.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.io/io.js Mon Feb  
7 23:32:03 2011
@@ -239,7 +239,7 @@ gadgets.io = function() {
    * @param {function(string,function(Object),Object,Object)}
    *     processResponseFunction The function that should process the
    *     response from the sever before calling the callback.
-   * @param {string=} opt_headers - Optional headers including a Content-Type 
that defaults to
+   * @param {Object=} opt_headers - Optional headers including a Content-Type 
that defaults to
    *     'application/x-www-form-urlencoded'.
    */
   function makeXhrRequest(realUrl, proxyUrl, callback, paramData, method,
@@ -257,8 +257,15 @@ gadgets.io = function() {
     }
     if (paramData !== null) {
       var contentTypeHeader = 'Content-Type';
+      var contentType = 'application/x-www-form-urlencoded';
+      if (typeof opt_headers === "string") {
+        // This turned out to come directly from a public API, so we need to
+        // keep compatibility...
+        contentType = opt_headers;
+        opt_headers = {};
+      }
       var headers = opt_headers || {};
-      if (!headers[contentTypeHeader]) headers[contentTypeHeader] = 
'application/x-www-form-urlencoded';
+      if (!headers[contentTypeHeader]) headers[contentTypeHeader] = 
contentType;
 
       for (var headerName in headers) {
         xhr.setRequestHeader(headerName, headers[headerName]);
@@ -267,8 +274,6 @@ gadgets.io = function() {
     xhr.send(paramData);
   }
 
-
-
   /**
    * Satisfy a request with data that is prefetched as per the gadget Preload
    * directive. The preloader will only satisfy a request for a specific piece


Reply via email to