aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNik Nyby <nikolas@gnu.org>2015-06-16 18:52:31 -0400
committerNik Nyby <nikolas@gnu.org>2015-06-16 18:52:31 -0400
commitce90f57c6abbef577900078041388ea5a85bb2ef (patch)
tree898d22b03797f3ca4b4b355059b6ebdc999abaf9 /lib
parentf38217420cc13a96633222cd95f3ac65ae74aa25 (diff)
downloadlibrejsxul-ce90f57c6abbef577900078041388ea5a85bb2ef.tar.lz
librejsxul-ce90f57c6abbef577900078041388ea5a85bb2ef.tar.xz
librejsxul-ce90f57c6abbef577900078041388ea5a85bb2ef.zip
apply Jookia's patch and update changelog
Diffstat (limited to 'lib')
-rw-r--r--lib/http_observer/process_response.js30
-rw-r--r--lib/http_observer/stream_loader.js2
2 files changed, 13 insertions, 19 deletions
diff --git a/lib/http_observer/process_response.js b/lib/http_observer/process_response.js
index c1f5e88..000daa2 100644
--- a/lib/http_observer/process_response.js
+++ b/lib/http_observer/process_response.js
@@ -81,17 +81,6 @@ var processResponseObject = {
},
/**
- * genBinaryOutput
- * Set or reset binaryOutputStream and storageStream.
- */
- genBinaryOutput: function () {
- this.storageStream = Cc["@mozilla.org/storagestream;1"]
- .createInstance(Ci.nsIStorageStream);
- this.binaryOutputStream = Cc["@mozilla.org/binaryoutputstream;1"]
- .createInstance(Ci.nsIBinaryOutputStream);
- },
-
- /**
* Gather the data gathered from onDataAvailable.
*/
setData: function () {
@@ -393,21 +382,26 @@ var processResponseObject = {
jsListenerCallback: function () {
- var len = this.data.length;
+ var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
+ .createInstance(Ci.nsIScriptableUnicodeConverter);
- this.genBinaryOutput();
+ if (typeof this.req.contentCharset !== 'undefined' &&
+ this.req.contentCharset !== '' &&
+ this.req.contentCharset !== null
+ ) {
+ converter.charset = this.req.contentCharset;
+ } else {
+ converter.charset = "utf-8";
+ }
- this.storageStream.init(8192, len, null);
- this.binaryOutputStream.setOutputStream(
- this.storageStream.getOutputStream(0));
- this.binaryOutputStream.writeBytes(this.data, len);
+ var stream = converter.convertToInputStream(this.data);
try {
this.listener.onDataAvailable(
this.req,
this.resInfo.context,
this.storageStream.newInputStream(0),
- 0, len);
+ 0, stream.available());
} catch (e) {
this.req.cancel(this.req.NS_BINDING_ABORTED);
}
diff --git a/lib/http_observer/stream_loader.js b/lib/http_observer/stream_loader.js
index cae11a7..a90e341 100644
--- a/lib/http_observer/stream_loader.js
+++ b/lib/http_observer/stream_loader.js
@@ -146,7 +146,7 @@ StreamListener.prototype.onDetermineCharset = function onDetermineCharset(
loader.channel.contentCharset = match[1];
return match[1];
} else {
- return "UTF-8";
+ return "utf-8";
}
}
};