finalize method
Finalizes the HTTP request in preparation for it being sent.
Freezes all mutable fields and returns a single-subscription ByteStream
that emits the body of the request.
The base implementation of this returns an empty 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
@override
ByteStream finalize() {
if (_bytes != null) return ByteStream.fromBytes(_bytes!);
_futureBytes ??= _getBytes();
return ByteStream(Stream.fromFuture(_futureBytes as Future<List<int>>));
}