Bug 735219 - Fix conflict between BigFile and Twitter's http.jsm files, r=bienvenu.
authorFlorian Quèze <florian@queze.net>
Tue, 13 Mar 2012 18:18:09 +0100
changeset 11095 3d368e502399d8b6ecfc936e5847d88dadb564d7
parent 11094 b3d3b3afb05c2cb942acb56b31655be1da4f738d
child 11096 a1dfd579042291583717e7e4513211840b0963d1
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs735219
Bug 735219 - Fix conflict between BigFile and Twitter's http.jsm files, r=bienvenu.
chat/modules/Makefile.in
mail/base/modules/http.jsm
mail/base/modules/oauth.jsm
--- a/chat/modules/Makefile.in
+++ b/chat/modules/Makefile.in
@@ -37,25 +37,28 @@
 DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 EXTRA_JS_MODULES = \
-	http.jsm \
 	imContentSink.jsm \
 	imServices.jsm \
 	imSmileys.jsm \
 	imStatusUtils.jsm \
 	imThemes.jsm \
 	imXPCOMUtils.jsm \
 	jsProtoHelper.jsm \
 	socket.jsm \
 	$(NULL)
 
+ifndef MOZ_THUNDERBIRD
+EXTRA_JS_MODULES += http.jsm
+endif
+
 EXTRA_PP_JS_MODULES = \
 	hiddenWindow.jsm \
 	imTextboxUtils.jsm \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/mail/base/modules/http.jsm
+++ b/mail/base/modules/http.jsm
@@ -1,21 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var EXPORTED_SYMBOLS = ["doXHRequest"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
-function doXHRequest(aUrl, aHeaders, aMethod, aPOSTData, aOnLoad, aOnError, aThis) {
+function doXHRequest(aUrl, aHeaders, aPOSTData, aOnLoad, aOnError, aThis, aMethod) {
   var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
               .createInstance(Ci.nsIXMLHttpRequest);
   xhr.mozBackgroundRequest = true; // no error dialogs
-  xhr.open(aMethod, aUrl);
+  xhr.open(aMethod || (aPOSTData ? "POST" : "GET"), aUrl);
   xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS | // don't send cookies
                           Ci.nsIChannel.LOAD_BYPASS_CACHE |
                           Ci.nsIChannel.INHIBIT_CACHING;
   xhr.onerror = function(aProgressEvent) {
     if (aOnError) {
       // adapted from toolkit/mozapps/extensions/nsBlocklistService.js
       let request = aProgressEvent.target;
       let status;
@@ -51,11 +51,19 @@ function doXHRequest(aUrl, aHeaders, aMe
   };
 
   if (aHeaders) {
     aHeaders.forEach(function(header) {
       xhr.setRequestHeader(header[0], header[1]);
     });
   }
 
-  xhr.send(aPOSTData);
+  let POSTData = aPOSTData || "";
+  if (Array.isArray(POSTData)) {
+    xhr.setRequestHeader("Content-Type",
+                         "application/x-www-form-urlencoded; charset=utf-8");
+    POSTData = aPOSTData.map(function(p) p[0] + "=" + encodeURIComponent(p[1]))
+                        .join("&");
+  }
+
+  xhr.send(POSTData);
   return xhr;
 }
--- a/mail/base/modules/oauth.jsm
+++ b/mail/base/modules/oauth.jsm
@@ -134,17 +134,17 @@ OAuth.prototype = {
     hmac.update(bytes, bytes.length);
     let signature = hmac.finish(true);
 
     params.push(["oauth_signature", encodeURIComponent(signature)]);
 
     let authorization =
       "OAuth " + params.map(function (p) p[0] + "=\"" + p[1] + "\"").join(", ");
     let headers = (aHeaders || []).concat([["Authorization", authorization]]);
-    return doXHRequest(url, headers, aMethod, aPOSTData, aOnLoad, aOnError, aThis);
+    return doXHRequest(url, headers, aPOSTData, aOnLoad, aOnError, aThis, aMethod);
   },
   _parseURLData: function(aData) {
     let result = {};
     aData.split("&").forEach(function (aParam) {
       let [key, value] = aParam.split("=");
       result[key] = value;
     });
     return result;