Prevent "add" after "close" on stream, 2.0.0-rc.1
This commit is contained in:
parent
d210456d44
commit
13538b5ddb
3 changed files with 38 additions and 31 deletions
|
@ -1,3 +1,6 @@
|
|||
# 2.0.0-rc.1
|
||||
* Fix logic error that allowed content to be written to streaming responses after `close` was closed.
|
||||
|
||||
# 2.0.0-rc.0
|
||||
* Log a warning when no `reflector` is provided.
|
||||
* Add `AngelEnvironment` class.
|
||||
|
|
|
@ -159,29 +159,31 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
|||
if (_isClosed && isBuffered)
|
||||
throw ResponseContext.closed();
|
||||
else if (!isBuffered) {
|
||||
_openStream();
|
||||
if (!_isClosed) {
|
||||
_openStream();
|
||||
|
||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||
if (_allowedEncodings != null) {
|
||||
for (var encodingName in _allowedEncodings) {
|
||||
Converter<List<int>, List<int>> encoder;
|
||||
String key = encodingName;
|
||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||
if (_allowedEncodings != null) {
|
||||
for (var encodingName in _allowedEncodings) {
|
||||
Converter<List<int>, List<int>> encoder;
|
||||
String key = encodingName;
|
||||
|
||||
if (encoders.containsKey(encodingName))
|
||||
encoder = encoders[encodingName];
|
||||
else if (encodingName == '*') {
|
||||
encoder = encoders[key = encoders.keys.first];
|
||||
}
|
||||
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;
|
||||
if (encoder != null) {
|
||||
data = encoders[key].convert(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rawResponse.add(data);
|
||||
rawResponse.add(data);
|
||||
}
|
||||
} else
|
||||
buffer.add(data);
|
||||
}
|
||||
|
|
|
@ -166,27 +166,29 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
|
|||
else if (!isBuffered) {
|
||||
_openStream();
|
||||
|
||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||
if (_allowedEncodings != null) {
|
||||
for (var encodingName in _allowedEncodings) {
|
||||
Converter<List<int>, List<int>> encoder;
|
||||
String key = encodingName;
|
||||
if (!_isClosed) {
|
||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||
if (_allowedEncodings != null) {
|
||||
for (var encodingName in _allowedEncodings) {
|
||||
Converter<List<int>, List<int>> encoder;
|
||||
String key = encodingName;
|
||||
|
||||
if (encoders.containsKey(encodingName))
|
||||
encoder = encoders[encodingName];
|
||||
else if (encodingName == '*') {
|
||||
encoder = encoders[key = encoders.keys.first];
|
||||
}
|
||||
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;
|
||||
if (encoder != null) {
|
||||
data = encoders[key].convert(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.sendData(data);
|
||||
stream.sendData(data);
|
||||
}
|
||||
} else
|
||||
buffer.add(data);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue