addStream method
Provide a stream that produces the content.
Note: any headers must be defined before this method is called. Headers cannot be defined after the stream has started.
Implementation
Future<ResponseStream> addStream(
Request req, Stream<List<int>> stream) async {
ArgumentError.checkNotNull(req);
if (_streamState == 1) {
throw StateError('addStream invoked when stream not finished');
}
if (_streamState == 0) {
// First invocation of addStream
super._outputHeaders(req);
}
_streamState = 1;
await req._streamBody(stream);
_streamState = 2;
return this;
}