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
|
# 2.0.0-rc.0
|
||||||
* Log a warning when no `reflector` is provided.
|
* Log a warning when no `reflector` is provided.
|
||||||
* Add `AngelEnvironment` class.
|
* Add `AngelEnvironment` class.
|
||||||
|
|
|
@ -159,29 +159,31 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
||||||
if (_isClosed && isBuffered)
|
if (_isClosed && isBuffered)
|
||||||
throw ResponseContext.closed();
|
throw ResponseContext.closed();
|
||||||
else if (!isBuffered) {
|
else if (!isBuffered) {
|
||||||
_openStream();
|
if (!_isClosed) {
|
||||||
|
_openStream();
|
||||||
|
|
||||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||||
if (_allowedEncodings != null) {
|
if (_allowedEncodings != null) {
|
||||||
for (var encodingName in _allowedEncodings) {
|
for (var encodingName in _allowedEncodings) {
|
||||||
Converter<List<int>, List<int>> encoder;
|
Converter<List<int>, List<int>> encoder;
|
||||||
String key = encodingName;
|
String key = encodingName;
|
||||||
|
|
||||||
if (encoders.containsKey(encodingName))
|
if (encoders.containsKey(encodingName))
|
||||||
encoder = encoders[encodingName];
|
encoder = encoders[encodingName];
|
||||||
else if (encodingName == '*') {
|
else if (encodingName == '*') {
|
||||||
encoder = encoders[key = encoders.keys.first];
|
encoder = encoders[key = encoders.keys.first];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoder != null) {
|
if (encoder != null) {
|
||||||
data = encoders[key].convert(data);
|
data = encoders[key].convert(data);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rawResponse.add(data);
|
rawResponse.add(data);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
buffer.add(data);
|
buffer.add(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,27 +166,29 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
|
||||||
else if (!isBuffered) {
|
else if (!isBuffered) {
|
||||||
_openStream();
|
_openStream();
|
||||||
|
|
||||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
if (!_isClosed) {
|
||||||
if (_allowedEncodings != null) {
|
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||||
for (var encodingName in _allowedEncodings) {
|
if (_allowedEncodings != null) {
|
||||||
Converter<List<int>, List<int>> encoder;
|
for (var encodingName in _allowedEncodings) {
|
||||||
String key = encodingName;
|
Converter<List<int>, List<int>> encoder;
|
||||||
|
String key = encodingName;
|
||||||
|
|
||||||
if (encoders.containsKey(encodingName))
|
if (encoders.containsKey(encodingName))
|
||||||
encoder = encoders[encodingName];
|
encoder = encoders[encodingName];
|
||||||
else if (encodingName == '*') {
|
else if (encodingName == '*') {
|
||||||
encoder = encoders[key = encoders.keys.first];
|
encoder = encoders[key = encoders.keys.first];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoder != null) {
|
if (encoder != null) {
|
||||||
data = encoders[key].convert(data);
|
data = encoders[key].convert(data);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stream.sendData(data);
|
stream.sendData(data);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
buffer.add(data);
|
buffer.add(data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue