addStream method
Adds a stream directly the underlying response.
If this instance has access to a correspondingRequest, then it will attempt to transform the content using at most one of the response encoders.
Implementation
@override
Future addStream(Stream<List<int>> stream) {
if (!isOpen && isBuffered) throw ResponseContext.closed();
_openStream();
var output = stream;
if (encoders.isNotEmpty && correspondingRequest != null) {
if (_allowedEncodings != null) {
for (var encodingName in _allowedEncodings!) {
Converter<List<int>, List<int>>? encoder;
var key = encodingName;
if (encoders.containsKey(encodingName)) {
encoder = encoders[encodingName];
} else if (encodingName == '*') {
encoder = encoders[key = encoders.keys.first];
}
if (encoder != null) {
output = encoders[key]!.bind(output);
break;
}
}
}
}
return output.forEach(this.stream.sendData);
}