anchor.diff:  
           // Upload all but the last chunk.
           // The final send will be done in the [onDone] handler.
  -        if (chunkStack.length > 1) {
  +        bool hasPartialChunk = chunkStack.hasPartialChunk;
  +        if (chunkStack.length > 1 ||
  +            (chunkStack.length == 1 && hasPartialChunk)) {
             // Pause the input stream.
             subscription.pause();
   
             // Upload all chunks except the last one.
  -          var fullChunks = chunkStack.removeSublist(0, chunkStack.length - 1);
  +          var fullChunks;
  +          if (hasPartialChunk) {
  +            fullChunks = chunkStack.removeSublist(0, chunkStack.length);
  +          } else {
  +            fullChunks = chunkStack.removeSublist(0, chunkStack.length - 1);
  +          }
             Future.forEach(fullChunks,
                            (c) => _uploadChunkDrained(uploadUri, c)).then((_) {
               // All chunks uploaded, we can continue consuming data.
  
positive.code:           chunkStack.finalize();
  
            var lastChunk;
            if (chunkStack.totalByteLength > 0) {
              assert(chunkStack.length == 1);
              lastChunk = chunkStack.removeSublist(0, chunkStack.length).first;
            } else {
              lastChunk = new ResumableChunk([], 0, 0);
            }
            var end = lastChunk.endOfChunk;
  
  
negative.code: import 'package:$packageName/src/common_internal.dart';
  import 'package:http/http.dart' as http;
  import 'package:unittest/unittest.dart';
  
  """ + r"""
  class HttpServerMock extends http.BaseClient {
    Function _callback;
  