title: Dart/Flutter HTTP response is incomplete when downloading large files
body: <p>I have a Dart/Flutter mobile app that configures itself by downloading files from a server.  The files are ZLib compressed, headlessly, and this process has always worked very well - up until now.  Here is the relevant code</p>
  <pre><code>static Future&lt;String&gt; fileFetch(String url) async
  {
   final HttpClientRequest request = await HttpClient().getUrl(Uri.parse(url));
   final HttpClientResponse response = await request.close();
   return await response.pipe(Accumulator());
  }
  </code></pre>
  <p>where the <code>Acccumulator</code> class handles the actual file download + ZLib decoding</p>
  <pre><code>import 'dart:io';
  import 'dart:async';
  
  
  class Accumulator extends StreamConsumer&lt;List&lt;int&gt;&gt;
  {
   List&lt;int&gt; accu = List.empty(growable:true);
  
   String originalText()
   {
    ZLibCodec zlc = ZLibCodec(raw:true);
    print('Accu ${accu.length}');
    List&lt;int&gt; uncompd = zlc.decode(accu);
    String text = String.fromCharCodes(uncompd); 
    return text;
   }
  
   void whenData(List&lt;int&gt; data){accu.addAll(data);}
  
   void whenErr(e){XLog.e('Accu',e.toString());}
  
   @override
   Future&lt;void&gt; addStream(Stream&lt;List&lt;int&gt;&gt; s) async
   {
    s.listen(whenData);
    return; 
   }
  
   @override 
   Future&lt;dynamic&gt; close() async
   {
    return Future.value(originalText());
   }
  }
  </code></pre>
  <p>For the most part the <code>orignalText</code> being returned is JSON.  The offending file that has now started causing an incomplete file download is 132Kb in length and I find that only 42894 bytes of the original (compressed) file are being downloaded.</p>
  <p>Why is this happening - intrinsic limits on how much can be handled by the Accumulator?</p>