Bug 1362099 - Make RESTRequest handle GET's where the response is > 8192 bytes and we know the charset r?markh draft
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Fri, 05 May 2017 16:29:01 -0400
changeset 573479 06085c80685a206c24400c76a4abd06036ddd9a5
parent 573462 9d46ca4e00c2c8111b1df15ab4cf185de23a2b50
child 627313 ed69dccbce0979812ec86f96c7653b356a260244
push id57405
push userbmo:tchiovoloni@mozilla.com
push dateFri, 05 May 2017 20:29:35 +0000
reviewersmarkh
bugs1362099
milestone55.0a1
Bug 1362099 - Make RESTRequest handle GET's where the response is > 8192 bytes and we know the charset r?markh MozReview-Commit-ID: 6g8hCvr7ZbJ
services/common/rest.js
--- 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 {