B2G/gecko/netwerk/test/httpserver/test/test_async_response_sending.js
/**
       * Increase the amount of data that can be written without blocking, but
       * do so by specifying a number of bytes that will be written each time
       * a write occurs, even as asyncWait notifications are initially triggered
       * as usual.  Thus, rather than writes eagerly writing everything possible
       * at each step, attempts to write out data by segment devolve into a
       * partial segment write, then another, and so on until the amount of data
       * specified as permitted to be written, has been written.
       *
       * Note that the writeByteArray method is incompatible with the previous
       * calling of this method, in that, until all increments provided to this
       * method have been consumed, writeByteArray cannot be called.  Once all
       * increments have been consumed, writeByteArray may again be called.
       *
       * @param increments : [uint]
       *   an array whose elements are positive numbers of bytes to permit to be
       *   written each time write() is subsequently called on this, ignoring
       *   the total amount of writable space specified by the sum of all
       *   increments
       */
Increase the amount of data that can be written without blocking, but
do so by specifying a number of bytes that will be written each time
a write occurs, even as asyncWait notifications are initially triggered
as usual.  Thus, rather than writes eagerly writing everything possible
at each step, attempts to write out data by segment devolve into a
partial segment write, then another, and so on until the amount of data
specified as permitted to be written, has been written.

Note that the writeByteArray method is incompatible with the previous
calling of this method, in that, until all increments provided to this
method have been consumed, writeByteArray cannot be called.  Once all
increments have been consumed, writeByteArray may again be called.

@param increments : [uint]
an array whose elements are positive numbers of bytes to permit to be
written each time write() is subsequently called on this, ignoring
the total amount of writable space specified by the sum of all
increments
Increase the amount of data that can be written without blocking but do so by specifying a number of bytes that will be written each time a write occurs even as asyncWait notifications are initially triggered as usual . Thus rather than writes eagerly writing everything possible at each step attempts to write out data by segment devolve into a partial segment write then another and so on until the amount of data specified as permitted to be written has been written . Note that the writeByteArray method is incompatible with the previous calling of this method in that until all increments provided to this method have been consumed writeByteArray cannot be called . Once all increments have been consumed writeByteArray may again be called . @param increments : [ uint ] an array whose elements are positive numbers of bytes to permit to be written each time write () is subsequently called on this ignoring the total amount of writable space specified by the sum of all increments
function makeWritableByIncrements(increments)
      {
        dumpn("*** [" + this.name + "].makeWritableByIncrements" +
              "([" + increments.join(", ") + "])");
        do_check_true(increments.length > 0, "bad increments");
        do_check_true(increments.every(function(v) { return v > 0; }),
                      "zero increment?");
        do_check_true(Components.isSuccessCode(self._status));
        this._writable += sum(increments);
        this._writableAmounts = increments;
        var waiter = this._waiter;
        if (waiter && !waiter.closureOnly &&
            waiter.requestedCount <= this._writable)
        {
          this._notify();
        }
      }
function makeWritableByIncrements ( increments ) { dumpn ( "*** [" + this . name + "].makeWritableByIncrements" + "([" + increments . join ( ", " ) + "])" ) ; do_check_true ( increments . length > 0 , "bad increments" ) ; do_check_true ( increments . every ( function ( v ) { return v > 0 ; } ) , "zero increment?" ) ; do_check_true ( Components . isSuccessCode ( self . _status ) ) ; this . _writable += sum ( increments ) ; this . _writableAmounts = increments ; var waiter = this . _waiter ; if ( waiter && ! waiter . closureOnly && waiter . requestedCount <= this . _writable ) { this . _notify ( ) ; } }
Increase the amount of data that can be written without blocking, but
 do so by specifying a number of bytes that will be written each time
 a write occurs, even as asyncWait notifications are initially triggered
 as usual.
Increase the amount of data that can be written without blocking but do so by specifying a number of bytes that will be written each time a write occurs even as asyncWait notifications are initially triggered as usual .