Prevent "add" after "close" on stream, 2.0.0-rc.1

This commit is contained in:
Tobe O 2019-04-11 10:34:13 -04:00
parent d210456d44
commit 13538b5ddb
3 changed files with 38 additions and 31 deletions

View file

@ -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.

View file

@ -159,6 +159,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
if (_isClosed && isBuffered)
throw ResponseContext.closed();
else if (!isBuffered) {
if (!_isClosed) {
_openStream();
if (encoders.isNotEmpty && correspondingRequest != null) {
@ -182,6 +183,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
}
rawResponse.add(data);
}
} else
buffer.add(data);
}

View file

@ -166,6 +166,7 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
else if (!isBuffered) {
_openStream();
if (!_isClosed) {
if (encoders.isNotEmpty && correspondingRequest != null) {
if (_allowedEncodings != null) {
for (var encodingName in _allowedEncodings) {
@ -187,6 +188,7 @@ class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
}
stream.sendData(data);
}
} else
buffer.add(data);
}