http
http copied to clipboard
`Bad state: Stream has already been listened to` when accessing response stream in `RetryClient.when`
Reading stream of response in when function of RetryClient causes Bad state: Stream has already been listened to to be thrown from https://github.com/dart-lang/http/blob/master/pkgs/http/lib/retry.dart#L125.
Possible fix:
try {
_unawaited(response.stream.listen((_) {}).cancel().catchError((_) {}));
} catch (_) {}