Added HttpResponseContext.detach
This commit is contained in:
parent
fdd1ca16c9
commit
be521dcd7f
1 changed files with 21 additions and 13 deletions
|
@ -15,10 +15,16 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
||||||
LockableBytesBuilder _buffer;
|
LockableBytesBuilder _buffer;
|
||||||
|
|
||||||
final HttpRequestContext _correspondingRequest;
|
final HttpRequestContext _correspondingRequest;
|
||||||
bool _isClosed = false, _streamInitialized = false;
|
bool _detached = false, _isClosed = false, _streamInitialized = false;
|
||||||
|
|
||||||
HttpResponseContext(this.rawResponse, this.app, [this._correspondingRequest]);
|
HttpResponseContext(this.rawResponse, this.app, [this._correspondingRequest]);
|
||||||
|
|
||||||
|
@override
|
||||||
|
HttpResponse detach() {
|
||||||
|
_detached = true;
|
||||||
|
return rawResponse;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RequestContext get correspondingRequest {
|
RequestContext get correspondingRequest {
|
||||||
return _correspondingRequest;
|
return _correspondingRequest;
|
||||||
|
@ -166,6 +172,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future close() {
|
Future close() {
|
||||||
|
if (!_detached) {
|
||||||
if (!_isClosed) {
|
if (!_isClosed) {
|
||||||
if (!isBuffered) {
|
if (!isBuffered) {
|
||||||
try {
|
try {
|
||||||
|
@ -182,6 +189,7 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
super.close();
|
super.close();
|
||||||
|
}
|
||||||
return new Future.value();
|
return new Future.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue