Bug 1362099 - Make RESTRequest handle GET's where the response is > 8192 bytes and we know the charset r?markh
MozReview-Commit-ID: 6g8hCvr7ZbJ
--- a/services/common/rest.js
+++ b/services/common/rest.js
@@ -518,24 +518,28 @@ RESTRequest.prototype = {
if (channel.contentCharset) {
this.response.charset = channel.contentCharset;
if (!this._converterStream) {
this._converterStream = Cc["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Ci.nsIConverterInputStream);
}
-
this._converterStream.init(stream, channel.contentCharset, 0,
this._converterStream.DEFAULT_REPLACEMENT_CHARACTER);
try {
- let str = {};
- let num = this._converterStream.readString(count, str);
- if (num != 0) {
+ let remaining = count;
+ while (remaining > 0) {
+ let str = {};
+ let num = this._converterStream.readString(remaining, str);
+ if (!num) {
+ break;
+ }
+ remaining -= num;
this.response.body += str.value;
}
} catch (ex) {
this._log.warn("Exception thrown reading " + count + " bytes from " +
"the channel", ex);
throw ex;
}
} else {