Using Dart's dart:io library, how can I tell if an HttpResponse is already closed?
I couldn't find a hint in the API docs: http://api.dartlang.org/docs/releases/latest/dart_io/HttpResponse.html
Stab in the dark here, but would connectionInfo being null mean that the HttpResponse has finished?
Otherwise, I guess you could set a "closed" bool variable from the Future returned by done, and test whether it's set before processing the response?
HttpResponse response = ...;
bool closed = false;
response.done.then((_) => closed = true);
if (!closed) {
...
}
But I'm not sure whether you could ever do this early enough, would depend on the scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With