From 8f1d6ed17e87e2ff22f19583df98da942ba069f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Wed, 22 Feb 2012 14:02:57 +0100 Subject: [PATCH] Backed out changeset 599a1a0c5fbe --- toolkit/components/telemetry/TelemetryPing.js | 34 ++----------------- .../tests/unit/test_TelemetryPing.js | 27 ++------------- 2 files changed, 5 insertions(+), 56 deletions(-) diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index d336e5195d3..3a9efdb6156 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -468,7 +468,7 @@ TelemetryPing.prototype = { request.mozBackgroundRequest = true; request.open("POST", url, true); request.overrideMimeType("text/plain"); - request.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); + request.setRequestHeader("Content-Type", "application/json"); let startTime = new Date(); @@ -486,37 +486,9 @@ TelemetryPing.prototype = { request.addEventListener("error", function(aEvent) finishRequest(request.channel), false); request.addEventListener("load", function(aEvent) finishRequest(request.channel), false); - request.setRequestHeader("Content-Encoding", "gzip"); - let payloadStream = Cc["@mozilla.org/io/string-input-stream;1"] - .createInstance(Ci.nsIStringInputStream); - payloadStream.data = this.gzipCompressString(data.payload); - request.send(payloadStream); + request.send(data.payload); }, - - gzipCompressString: function gzipCompressString(string) { - let observer = { - buffer: "", - onStreamComplete: function(loader, context, status, length, result) { - this.buffer = String.fromCharCode.apply(this, result); - } - }; - - let scs = Cc["@mozilla.org/streamConverters;1"] - .getService(Ci.nsIStreamConverterService); - let listener = Cc["@mozilla.org/network/stream-loader;1"] - .createInstance(Ci.nsIStreamLoader); - listener.init(observer); - let converter = scs.asyncConvertData("uncompressed", "gzip", - listener, null); - let stringStream = Cc["@mozilla.org/io/string-input-stream;1"] - .createInstance(Ci.nsIStringInputStream); - stringStream.data = string; - converter.onStartRequest(null, null); - converter.onDataAvailable(null, null, stringStream, 0, string.length); - converter.onStopRequest(null, null, null); - return observer.buffer; - }, - + attachObservers: function attachObservers() { if (!this._initialized) return; diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js index 5e2c5f6d055..f85a8609996 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js @@ -57,31 +57,8 @@ function checkHistograms(request, response) { // do not need the http server anymore httpserver.stop(do_test_finished); let s = request.bodyInputStream; - let payload = null; - let decoder = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON) - - if (request.getHeader("content-encoding") == "gzip") { - let observer = { - buffer: "", - onStreamComplete: function(loader, context, status, length, result) { - this.buffer = String.fromCharCode.apply(this, result); - } - }; - - let scs = Cc["@mozilla.org/streamConverters;1"] - .getService(Ci.nsIStreamConverterService); - let listener = Cc["@mozilla.org/network/stream-loader;1"] - .createInstance(Ci.nsIStreamLoader); - listener.init(observer); - let converter = scs.asyncConvertData("gzip", "uncompressed", - listener, null); - converter.onStartRequest(null, null); - converter.onDataAvailable(null, null, s, 0, s.available()); - converter.onStopRequest(null, null, null); - payload = decoder.decode(observer.buffer); - } else { - payload = decoder.decodeFromStream(s, s.available()); - } + let payload = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON) + .decodeFromStream(s, s.available()); do_check_eq(request.getHeader("content-type"), "application/json; charset=UTF-8"); do_check_true(payload.simpleMeasurements.uptime >= 0);