add method
Adds a data event
to the sink.
Must not be called on a closed sink.
Implementation
@override
void add(List<int> data) {
if (!isOpen && isBuffered) {
throw ResponseContext.closed();
} else if (!isBuffered) {
_openStream();
if (!_isClosed) {
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) {
data = encoders[key]!.convert(data);
break;
}
}
}
}
stream.sendData(data);
}
} else {
buffer!.add(data);
}
}