finalize method

ByteStream finalize ()

Finalizes the HTTP request in preparation for it being sent. This freezes all mutable fields and returns a single-subscription ByteStream that emits the body of the request.

The base implementation of this returns null rather than a ByteStream; subclasses are responsible for creating the return value, which should be single-subscription to ensure that no data is dropped. They should also freeze any additional mutable fields they add that don't make sense to change after the request headers are sent.

Implementation

ByteStream finalize() {
  // TODO(nweiz): freeze headers
  if (finalized) throw new StateError("Can't finalize a finalized Request.");
  _finalized = true;
  return null;
}